平台:Ubuntu16.04(x64)
1.安装nginx、
uwsgi 、web.py
apt-get install nginx 安装完我的版本为1.10.3
apt-get install uwsgi 安装完我的版本为2.0.12
apt-get install web.py 安装完我的版本为0.38
2.写一个简单的基于web.py的测试程序test.py
-
import web
-
-
urls = (
-
'/(.*)', 'hello'
-
)
-
-
app = web.application(urls, globals())
-
-
class hello:
-
def GET(self, name):
-
if not name:
-
name = "World"
-
return "Hello" + name + "!"
-
-
application = app.wsgifunc()
3.启动uwsgi
uwsgi -s 127.0.0.1:9000 --plugin python --wsgi-file test.py &
4.配置并启动nginx
修改配置文件/etc/nginx/sites-enabled/default
-
server {
-
listen 80;
-
-
root /var/www/html;
-
index index.html index.htm index.nginx-debian.html;
-
-
server_name 0.0.0.0;
-
-
location / {
-
# First attempt to serve request as file, then
-
# as directory, then fall back to displaying a 404.
-
uwsgi_pass 127.0.0.1:9000;
-
include uwsgi_params;
-
uwsgi_param UWSGI_SCHEME $scheme;
-
uwsgi_param SERVER_SOFTWARE nginx/$nginx_version;
-
}
-
}
启动nginx:/etc/init.d/nginx restart
阅读(1667) | 评论(0) | 转发(0) |