Centos6下nginx + web.py配置

原创
2012/12/23 11:19
阅读数 271
1. 安裝 web.py
wget http://webpy.org/static/web.py-0.37.tar.gz
tar -zxvf ./web.py-0.37.tar.gz
cd web.py-0.37
python ./setup.py install
2. 安裝spawn-fcgi和python-flup
yum install spawn-fcgi python-flup
3.啟動fastcgi
spawn-fcgi -d /data/web1 -f 'python /data/web1/hello.py' -a 127.0.0.1 -p 9002
#/data/web1 是 網站所在目錄
#關閉fastcgi命令 kill `pgrep -f "python /data/web1/hello.py"`
4.配置並啟動nginx
location /favicon.ico {
		root /data/web1;
}
location /static/ {
		root /data/web1;
}
location / {
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
    fastcgi_param REMOTE_ADDR $remote_addr;
    fastcgi_param REMOTE_PORT $remote_port;
    fastcgi_param SERVER_ADDR $server_addr;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_NAME $server_name;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    #以上可用 include fastcgi_params; 代替

    fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
    fastcgi_param PATH_INFO $fastcgi_script_name;
    fastcgi_pass 127.0.0.1:9002; 
}
展开阅读全文
打赏
0
1 收藏
分享
加载中
更多评论
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部