Configuring UWSGI with Python, Django, and NGINX: Difference between revisions

No edit summary
No edit summary
Line 45: Line 45:
threads=2
threads=2


http = 0.0.0.0:8001
http = 0.0.0.0:8001</pre>
 
Now start uwsgi
 
<pre>sudo service uwsgi start</pre>
 
Check that the service and your application are running at:
 
<pre>http://www.lab.bpopp.net:8001</pre>

Revision as of 12:43, 1 November 2020

Install uwsgi:

apt-get install build-essential python
sudo pip3 install uwsgi

Create a service in /etc/systemd/system/uwsgi.service

[Unit]
Description=uWSGI Emperor service

[Service]
ExecStartPre=/bin/bash -c 'mkdir -p /run/uwsgi; chown www-data: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

Create an emperor file at:

sudo mkdir /etc/uwsgi
sudo mkdir /etc/uwsgi/sites
sudo vi /etc/uswsgi/sites/stocks.ini

And then add:

[uwsgi]
project = stocks
uid = bpopp
base = /usr/share/nginx/html/django

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

master = true
processes = 5
threads=2

http = 0.0.0.0:8001

Now start uwsgi

sudo service uwsgi start

Check that the service and your application are running at:

http://www.lab.bpopp.net:8001