Install Uwsgi and Nginx. If you want UWSGI support python,you must install "Uwsgi-plugin-python"
sudo apt-get updatesudo apt-get install Uwsgi uwsgi-plugin-python nginx
First,we Create a simple Python script named "index.py" with Directry/home/ubuntu/html.like this:
#!/usr/bin/env python#-*-coding:utf-8-*-import weburls = ( '/.* ', "hello") class Hello: def GET (self): Return ' Hello world! ' #if __name__ = = ' __main__ ': app = web.application (URLs, Globals ()) application = App.wsgifunc ()
then,configure uwsgi config file. You can create new file named ' My.ini ' in/etc/uwsgi/apps-enabled
[Uwsgi]gid = Www-datauid = Www-datavhost = truelogdate## Use UNIX socket instead of TCP Socket.socket =/tmp/manage.so Ckmaster = trueprocesses = 1harakiri = 20limit-as = 128memory-reportno-orphans## That's important for UWSGI support Python . plugin = Python
last,configure nginx config file.change The default config of Nginx. You can input this content cover the whole of/etc/nginx/sites-enabled/default
server { listen; server_name localhost; Location/{ Uwsgi_pass unix:///tmp/manage.sock; Uwsgi_param uwsgi_chdir/home/ubuntu/html; Uwsgi_param uwsgi_pyhome/home/ubuntu/html; Uwsgi_param uwsgi_script index; }
Now,it ' s complete after restart Nginx and Uwsgi service.
sudo service nginx restartsudo service Uwsgi restart
congratulations~!
Uwsgi+web.py+nginx on Ubuntu14.04 LTS