Question
Need some help completing deployment of Django site on Nginx from local computer
I followed this tutorial for setting up uwsgi and Nginx on Ubunutu
The guide shows how to setup two fresh Django sites, I just did the first one and that is now working here
for the second site I want to deploy a Django blog I had built locally, put it on the same ip and serve it on port :8080 so then I followed this tutorial
https://www.digitalocean.com/community/tutorials/how-to-deploy-a-local-django-app-to-a-vps
I have followed everything in the guide apart from the GUnicorn part as I believe I dont need that if I have Uwsgi.
Ive cloned my site there, setup psql, migrated the db and finally done collecstatic and they all seem to have worked without any problems, I can run the site and see it at :8080 if I do manage.py runserver 0.0.0.0:8080 but if I just go to that port normally then I get an ‘internal server error’.
The following is my setup for uwsgi and Nginx, its almost exactly the same as what I did for 'first site’ however I should add that the second tutorial had somethings a bit different for the Nginx server block setup which Im not sure if I need so I have commented those out (e.g. proxy_pass etc)
/etc/uwsgi/sites/codego.ini
[uwsgi]
project = codego
uid = david
base = /home/david
chdir = /home/david/codego/codego
home = /home/david/Env/codego
module = codego.wsgi:application
master = true
processes = 5
socket = /run/uwsgi/codego.sock
chown-socket = david:www-data
chmod-socket = 666
vacuum = true
/etc/systemd/system/uwsgi.service
[Unit]
Description=uWSGI Emperor service
[Service]
ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown david:www-data /run/uwsgi’
ExecStart=/usr/local/bin/uwsgi –emperor /etc/uwsgi/sites
Restart=always
KillSignal=SIGQUIT
Type=notify
NotifyAccess=all
[Install]
WantedBy=multi-user.target
/etc/nginx/sites-available/codego
server {
listen 8080;
server_name = 128.199.120.162;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/david/codego;
}
location / {
#proxy_pass http://127.0.0.1:8001;
#proxy_set_header X-Forwarded-Host $server_name;
#proxy_set_header X-Real-IP $remote_addr;
#add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/codego.sock;
}
}
Ive been banging my head against this for hrs now and still can’t figure it out.
I should add btw that my wigs.py file was blank for some reason so I had to manually add that content there from local and also Nginx error logs dont seem to be logging anything for some reason.
Any advice would be appreciated, I think Im very close to finishing this setup!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×