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 in 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.sockmaster = 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/defaultserver { listen 80; 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,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。