六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 63|回复: 0

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

[复制链接]

升级  30%

3

主题

3

主题

3

主题

童生

Rank: 1

积分
15
 楼主| 发表于 2013-1-28 16:33:37 | 显示全部楼层 |阅读模式
环境:ubuntu10.10 + python2.6
 
步骤说明:
编译安装nginx:

  • apt-get install build-essential
  • apt-get build-dep nginx
  • wget http://nginx.org/download/nginx-0.9.6.tar.gz and decompress
  • ./configure --prefix=/usr/local/nginx --with-http_ssl_module
  • make && make install
 
编译安装uwsgi:

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

  • apt-get install python-pip
  • 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/。
 
结束。
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表