Configure multiple uwsgi application on nginx
Configure multiple uwsgi application on nginx
Date Posted: 16-08-2018
In our previous posts, we explained on how to configure uwsgi application on nginx. In this post, we will explain on how to configure multiple uwsgi application on nginx.
There two places we need to add configuration files to accomplish this task.
- uwsgi ini config
- uwsgi ini config
uwsgi ini config
File path is /etc/uwsgi/vassals/demo.ini which is a softlink to /var/www/pheonix/apiv2demo/pheonix/demo.ini
cd /etc/uwsgi/vassals/
ln -s /var/www/pheonix/apiv2demo/pheonix/demo.ini .
Copy the contents and paste in above file.
# mysite_uwsgi.ini file [uwsgi] # Django-related settings # the base directory (full path) chdir = /var/www/pheonix/apiv2demo/pheonix # Django's wsgi file module = pheonix.wsgi enable-threads = true # process-related settings # master master = true # maximum number of worker processes processes = 10 listen = 100 # the socket (use the full path to be safe socket = /var/www/pheonix/apiv2demo/pheonix/pheonix.sock # ... with appropriate permissions - may be needed chmod-socket = 666 # clear environment on exit vacuum = true max-requests = 1000 #limit-as = 128 #daemonize = /var/log/uwsgi-emperor.log
uwsgi ini config
File path is /etc/nginx/conf.d/cms.pheonix.com.conf
upstream pheonix { server unix:///var/www/pheonix/apiv2demo/pheonix/pheonix.sock; # for a file socket } server { # the port your site will be served on listen 80; # the domain name it will serve for server_name pheonixsolutions.com; # substitute your machines IP address or FQDN charset utf-8; # max upload size client_max_body_size 75M; # adjust to taste location /media { alias /var/www/pheonix/apiv2demo/pheonix/pheonix/lib/python2.7/site-packages/rest_framework/media; } location /static { alias /var/www/pheonix/apiv2demo/pheonix/pheonix/lib/python2.7/site-packages/rest_framework/static; # your Django project's static files } # Finally, send all non-media requests to the Django server. location / { uwsgi_pass pheonix; include /etc/nginx/uwsgi_params; # the uwsgi_params file you installed } }
Verify nginx syntax:
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Restart nginx:
systemctl restart nginx
Restart uwsgi service:
/opt/scripts/uwsgi_restart.sh