Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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!
Works! Great tutorial! Have one question: I use env. variable in my settings.py like os.environ.get(‘DB_NAME’), but they are not working. Any idea why they dont work?
Hi there,
Followed this tutorial to the T (great job by the way!). However, I am getting a 502 bad gateway error. I got to the part with the Django server, and it worked correctly, its the UWSGI config that must’ve caused the 502. Any ideas?
Like @tbrightbill, i get a 502 error. Seems like it can’t create the socket. https://gist.github.com/anonymous/40284b9c84bea2df6fca
This comment has been deleted
I was able to make the uwsgi start using uwsgi --http :8080 --home /home/user/Env/firstsite --chdir /home/user/firstsite -w firstsite.wsgi
I was not able to start using uwsgi configuration file, there is no port mention in the uwsgi config file.
Where is the use of setgid www-data?
How to mention server name in nginx if I have IP address ?
Hi there,
I have followed your setup.
The issue I continue to have is that only the firstsite.sock (in my case, it’s called djangoonpy2.sock) is showing up. The secondsite.sock is NOT.
These are my following files:
/etc/nginx/sites-enabled/djangoonpy2.conf
server {
listen 80;
server_name djangoonpy2.app;
location = favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /src/Apps/djangoonpy2;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/djangoonpy2.sock;
}
}
/etc/nginx/sites-enabled/djangoonpy3.conf
server {
listen 80;
server_name djangoonpy3.app;
location = favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /src/Apps/djangoonpy3;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/djangoonpy3.sock;
}
}
/etc/init/uwsgi.conf
description "uWSGI application server in Emperor mode"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
pre-start script
mkdir -p /run/uwsgi
chown vagrant:www-data /run/uwsgi
end script
exec /usr/local/bin/uwsgi --emperor /etc/uwsgi/sites
/etc/uwsgi/sites/djangoonpy2.ini
[uwsgi]
project = djangoonpy2
username = vagrant
projectbase = /src/Apps
userbase = /home/%(username)
chdir = %(projectbase)/%(project)
home = %(userbase)/.virtualenvs/%(project)
module = %(project).wsgi:application
master = true
processes = 5
uid = %(username)
socket = /run/uwsgi/%(project).sock
chown-socket = %(username):www-data
chmod-socket = 664
vacuum = true
/etc/uwsgi/sites/djangoonpy3.ini
[uwsgi]
project = djangoonpy3
username = vagrant
projectbase = /src/Apps
userbase = /home/%(username)
chdir = %(projectbase)/%(project)
home = %(userbase)/.virtualenvs/%(project)
module = %(project).wsgi:application
master = true
processes = 5
uid = %(username)
socket = /run/uwsgi/%(project).sock
chown-socket = %(username):www-data
chmod-socket = 664
vacuum = true
I have also done:
sudo usermod -a -G vagrant www-data
I have also chmod /src/Apps as 755
Why did I use /run/uwsgi?
Because for some reason using /home/username just doesn’t work.
UPDATE
I tried uwsgi --http :8080 --home ~/.virtualenvs/djangoonpy2 --chdir /src/Apps/djangoonpy2 -w djangoonpy2.wsgi
which works
I tried uwsgi --http :8080 --home ~/.virtualenvs/djangoonpy3 --chdir /src/Apps/djangoonpy3 -w djangoonpy3.wsgi
which failed because I get a ImportError no module named site
I surmised this has to do with the fact that the global uwsgi is for python2.
So I removed djangoonpy3.ini from /etc/uwsgi/sites and then proceeded to create another virtualenv, another project, etc named seconddjangoonpy2
this time it worked.
My question is, how do I run multiple django apps using uwsgi and nginx on ubuntu 14.04 where one of them is on python 3 and the rest are on python 2?
Hi, Thanks for tutorial. I followed all the steps, but when i run
sudo service uwsgi start
I got the following error:
Failed to start uwsgi.service: Unit uwsgi.service failed to load: No such file or directory.
I am running Ubuntu 15.04. Is that the problem?
my uswgi.conf file is:
description "uWSGI application server in Emperor mode"
start on runlevel [2345]
stop on runlevel [!2345]
setuid rijo
setgid www-data
exec /usr/local/bin/uwsgi --emperor /etc/uwsgi/sites/ --logto /var/log/uwsgi.log
my ini file is:
[uwsgi]
project = mysterybox
base = /home/rijo
chdir = %(base)/%(project)
home = %(base)/Env/%(project)
module = %(project).wsgi:application
master = true
processes = 5
socket = %(base)/%(project)/%(project).sock
chmod-socket = 664
vacuum = true
Thanks :)