I am trying to find an optimal way to set up my server to use NGINX and UWSGI to serve python applications. The following has worked so far:
Initial setup:
sudo apt-get install nginx uwsgi uwsgi-plugin-http uwsgi-plugin-python python-setuptools
easy_install pip
pip install web.py
/etc/nginx/sites-available/default:
server {
listen 80;
server_name localhost;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9090;
}
}
And then I have a basic myapp.py (location doesn't matter for the current setup):
import web
urls = (
'/', 'index'
)
app = web.application(urls, globals())
class index:
def GET(self):
return "Hello from Web.py!"
application = app.wsgifunc()
Then I can issue the following commands and everything works:
sudo service nginx restart
uwsgi --plugins http,python -s 127.0.0.1:9090 myapp
So it works, but it's not very pretty. I noticed that when I installed UWSGI with apt-get
that two directories were created: /etc/uwsgi/apps-available
and /etc/uqsgi/apps-enabled
. This matches the convention for debian servers running NGINX or Apache only with apps
instead of sites
.
Here is what would be awesome: I would like to be able to drop in application configurations to apps-available
(creating symlinks in apps-enabled
as needed) and have the UWSGI service pick them up. But I don't quite know where to start. What configuration files do I put in apps-available
? And what does the NGINX configuration look like for passing to the uwsgi service rather than passing to the socket created by the command I issued earlier?