How to deal with it.
--Server: nginx
nginx.conf
#server{}Added in
location / {
root /home/hogehoge/hogehoge; #Application directory path on the server
proxy_pass http://127.0.0.1:8000;
}
At the time of deployment, I set it like this.
In settings.py, rewrite the following contents.
settings.py
DEBUG = False
ALLOWED_HOSTS = ['127.0.0.1','Any DNS']
STATIC_ROOT = "/home/hogehoge/hogehoge/static" #It seems to specify the path where you want to put the static file
#In addition to this, STATIC FILES_DIRS = {... seems to comment out
If this is left as it is, the static file will be hidden, so
python manage.py collectstatic
Execute. Then rewrite the settings with nginx
nginx.conf
#server{}In
location /static/ {
alias /home/hogehoge/hogehoge/static/; #settings.Describe the same location set in py
}
I will write it like this. that's all.
Recommended Posts