LNMP环境源安装web.py

来自:互联网
时间:2018-08-12
阅读:

空余时间想测试个web.py,经过多次搜索终于成功运行web.py,过程如下: yJK免费资源网

安装Web.py yJK免费资源网

apt-get install python-setuptools 
easy_install flup 
easy_install web.py 
easy_install Jinja2 
easy_install MySQL-python

配置Web.py yJK免费资源网

mkdir -p /home/www/jymmbb

vi /etc/nginx/vhost/jymmbb.conf yJK免费资源网

server { 
listen 80; 
server_name dev.jymmbb.com; 
root /home/www/jymmbb; 
 
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; 
} 
 
location /static/ { 
if (-f $request_filename) { 
rewrite ^/static/(.*)$ /static/$1 break; 
} 
} 
 
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { 
expires 30d; 
} 
 
location ~ .*\.(js|css)?$ { 
expires 12h; 
} 
 
access_log /home/log/jymmbb.log access; 
}

重启Nginx yJK免费资源网

/etc/init.d/nginx restart

测试Web.py,vi /home/www/jymmbb/main.py yJK免费资源网

#!/usr/bin/env python 
# -*- coding: utf-8 -*- 
 
import web 
 
urls = ("/.*", "hello") 
app = web.application(urls, globals()) 
 
class hello: 
def GET(self): 
return 'Hello, world!' 
 
if __name__ == "__main__": 
web.wsgi.runwsgi = lambda func, addr=None: web.wsgi.runfcgi(func, addr) 
app.run()

添加权限 yJK免费资源网

chown -R www-data:www-data /home/www 
chmod +x /home/www/jymmbb/main.py

启动 yJK免费资源网

/usr/bin/spawn-fcgi -a 127.0.0.1 -p 9002 -d /home/www/jymmbb -f /home/www/jymmbb/main.py

关闭 yJK免费资源网

kill `pgrep -f "python /home/www/jymmbb/main.py"`

如果需要检查应用程序是否运行,使用 yJK免费资源网

ps aux|grep main.py
返回顶部
顶部