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!
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Found the problem, my directory structure was causing this I think as I had too many folders within folders and not named correctly, after removing everything in the Env and starting again for that Django install but this time with a more simple folder structure I seem to have it right and can see the site at :8080.
@easycompany80
Have you checked the log files generated by NGINX?
The above will display the last 20 lines of the
error.log
and may have more information as to why you’re receiving the ISE.and could file ownership be the problem? This is what ls -ld gives me:
drwxr-xr-x 3 root root 4096 Feb 5 04:28 /home drwxr-xr-x 9 david david 4096 Feb 12 04:54 /home/david drwxr-xr-x 3 david root 4096 Feb 10 14:07 /home/david/codego drwxr-xr-x 6 david root 4096 Feb 11 05:48 /home/david/codego/codego