Wiring uWSGI to work with Django and nginx on Ubuntu 16.04

The first modification needed is to the /etc/uwsgi/sites/firstsite.ini file. The only change needed is replacing the permissions from 664 to 666. The script would look like this:

[uwsgi]
project = firstsite
base = /home/user

chdir = %(base)/%(project)
home = %(base)/Env/%(project)
module = %(project).wsgi:application

master = true
processes = 5

socket = %(base)/%(project)/%(project).sock
chmod-socket = 666
vacuum = true

Secondly, as we're using systemd rather than upstart, the following file is not needed and can be removed: /etc/init/uwsgi.conf

Third, we create the following systemd script at /etc/systemd/system/uwsgi.service:

[Unit]
Description=uWSGI Emperor service
After=syslog.target

[Service]
ExecStart=/usr/local/bin/uwsgi --emperor /etc/uwsgi/sites
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all

[Install]
WantedBy=multi-user.target

Refresh the state of the systemd init system with this new uWSGI service on board

sudo systemctl daemon-reload

In order to start the script you'll need to run the following:

sudo systemctl start uwsgi

In order to start uWSGI on reboot, you will also need:

sudo systemctl enable uwsgi

You can use the following to check its status:

systemctl status uwsgi

Some further details can be found here.