ubuntu+nginx+uwsgi+webpy配置简要说明

环境:ubuntu10.10 + python2.6

 

步骤说明:

编译安装nginx:

  1. apt-get install build-essential
  2. apt-get build-dep nginx
  3. wget http://nginx.org/download/nginx-0.9.6.tar.gz and decompress
  4. ./configure --prefix=/usr/local/nginx --with-http_ssl_module
  5. make && make install

 

编译安装uwsgi:

  1. apt-get install python2.6-dev libxml2-dev
  2. wget http://projects.unbit.it/downloads/uwsgi-0.9.7.1.tar.gz and decompress
  3. make -f Makefile.Py26
  4. cp uwsgi /usr/local/nginx (anywhere you like)

 

安装webpy:

  1. apt-get install python-pip
  2. pip install web.py

 

nginx配置:

 

    server {
        listen       8000;
        server_name  somename  alias  another.alias;
        error_log logs/test.log;

        location / {
            root   html;
            uwsgi_pass 127.0.0.1:9001;
            include uwsgi_params;
            index  index.html index.htm;
        }
    }

 

 测试脚本test.py:

import web
 
urls = (
        '/', 'index'
)
 
class index:
    def GET(self):
        return "Hello, world!"
 
app = web.application(urls, locals())
application = app.wsgifunc()

 将测试脚本放在nginx的webroot下(缺省为html)。进入html目录,运行命令:

/usr/local/nginx/uwsgi -s 127.0.0.1:9001 -w test
 

访问http://localhost:8000/。

 

结束。

你可能感兴趣的:(Web,nginx,python,脚本,ubuntu)