wsp网站开发,网站推广信息,江苏网站备案,加油站顶棚网架价多少钱一平web.py 是一个轻量级Python web框架#xff0c;它简单而且功能大。web.py是一个开源项目。1、所需要的软件#xff1a;Nginx nginx-1.4.7.tar.gz (需要包含fastcgi和rewrite模块)。Webpy 0.32Spawn-fcgi 1.6.2Flup注意#xff1a;Flup是最常见的忘记装的软件#xff0c;需要…web.py 是一个轻量级Python web框架它简单而且功能大。web.py是一个开源项目。1、所需要的软件Nginx nginx-1.4.7.tar.gz (需要包含fastcgi和rewrite模块)。Webpy 0.32Spawn-fcgi 1.6.2Flup注意Flup是最常见的忘记装的软件需要安装更老的版本应该也可以工作但是没有测试过最新的是可以工作的2、安装软件安装nginxwget http://nginx.org/download/nginx-1.4.7.tar.gztar zxvf nginx-1.4.7.tar.gzcd nginx-1.4.7yum -y install pcre pcre-devel./configure --prefix/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_stub_status_modulemake make install安装web.py、Spawn-fcgi 、Flup安装spawn-fcgiwget http://www.lighttpd.net/download/spawn-fcgi-1.6.3.tar.gztar zxvf spawn-fcgi-1.6.3.tar.gz./configuremake make install安装fluppip install flup安装web.pypip install web.pynginx配置文件server {listen 80;server_name localhost;root /usr/local/nginx/html/webpy;location / {include fastcgi_params;fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;fastcgi_param PATH_INFO $fastcgi_script_name;fastcgi_pass 127.0.0.1:9002;}error_page 500 502 503 504 /50x.html;location /50x.html {root html;}location /static/ {if (-f $request_filename) {rewrite ^/static/(.*)$ /static/$1 break;}}}检查配置文件并启动nginx[roottest controllers]# /usr/local/nginx/sbin/nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful[roottest controllers]# /usr/local/nginx/sbin/nginx在web跟目录创建一个python文件将下面的代码保存为index.py(或者任何你喜欢的)注意使用Nginx配置的话web.wsgi.runwsgi lambda func, addrNone: web.wsgi.runfcgi(func, addr)这一行代码是必须的。#!/usr/bin/env python# -*- coding: utf-8 -*-import weburls (/.*, hello)app web.application(urls, globals())class hello:def GET(self):return Hello, world! 3305if __name__ __main__:web.wsgi.runwsgi lambda func, addrNone: web.wsgi.runfcgi(func, addr)app.run()注意: 同样需要给代码设置权限代码如下chmod x index.py。启动和关闭Spawn-fcgi启动spawn-fcgispawn-fcgi -d /path/to/www -f /path/to/www/index.py -a 127.0.0.1 -p 9002关闭Spawn-fcgikill pgrep -f python /path/to/www/index.py在浏览器上输入 IP访问出现如下图所示