Nginx + uWSGI + web.py 搭建示例
2014-06-02 17:46
323 查看
(1)安装Nginx
1.1 下载nginx-1.0.5.tar.gz并解压
1.2 ./configure (也可以增加--prefix= path指定安装路径)
此时有可能会提示缺少pcre支持,如果要安装pcre的话可以通过 yum install pcre-devel 来实现安装
1.3 make
1.4 make install
(2)安装uWSGI
2.1 下载uwsgi-0.9.8.2.tar.gz并解压
2.2 make
在安装uWSGI的时候有可能提示说是libxml2不存在,针对此情况,建议通过 yum install libxml2-devel来解决
(3)安装web.py
可以通过easy_install web.py来安装最新版,不过我在安装0.36的时候出错,而且是语法错误,所以最终回退到0.35版
(4)以一个简单的webpy程序作为示例。以下代码是一个完整的webpy程序(webpytest.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()
最后一句的application = app.wsgifunc()是关键,此时才可以通过wsgi进行访问
(5)启动uWSGI
uwsgi -s 127.0.0.1:9000 -w webpytest
(6)更改Nginx相关配置(nginx.conf)
server {
listen 80;
server_name 10.0.11.226;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9000;
uwsgi_param UWSGI_CHDIR /usr/local/sphinx;
uwsgi_param UWSGI_SCRIPT webpytest;
}
注意:uwsgi_pass 的相关配置必须和启动uwsgi时的一致!UWSGI_CHDIR是指程序所在的目录,UWSGI_SCRIPT是指启动哪个程序(注意,这里必须去掉py后缀).测试发现,UWSGI_CHDIR 和UWSGI_SCRIPT也可以不要!
(6)启动nginx
/usr/local/nginx/sbin/nginx
重启nginx命令为(/usr/local/nginx/sbin/nginx -s stop)
遇到的问题: 1)提示找不到 libpcre.so.1
解决办法:如果是32位系统,ln -s /usr/local/lib/libpcre.so.1 /lib
如果是64位系统,ln -s /usr/local/lib/libpcre.so.1 /lib64
(7)通过http即可访问 http://10.0.11.226
以上只是一个非常简单的搭建过程,仅作记录!
来源:http://blog.ops.cc/hosting/22935dcc7d57e320.html
1.1 下载nginx-1.0.5.tar.gz并解压
1.2 ./configure (也可以增加--prefix= path指定安装路径)
此时有可能会提示缺少pcre支持,如果要安装pcre的话可以通过 yum install pcre-devel 来实现安装
1.3 make
1.4 make install
(2)安装uWSGI
2.1 下载uwsgi-0.9.8.2.tar.gz并解压
2.2 make
在安装uWSGI的时候有可能提示说是libxml2不存在,针对此情况,建议通过 yum install libxml2-devel来解决
(3)安装web.py
可以通过easy_install web.py来安装最新版,不过我在安装0.36的时候出错,而且是语法错误,所以最终回退到0.35版
(4)以一个简单的webpy程序作为示例。以下代码是一个完整的webpy程序(webpytest.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()
最后一句的application = app.wsgifunc()是关键,此时才可以通过wsgi进行访问
(5)启动uWSGI
uwsgi -s 127.0.0.1:9000 -w webpytest
(6)更改Nginx相关配置(nginx.conf)
server {
listen 80;
server_name 10.0.11.226;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9000;
uwsgi_param UWSGI_CHDIR /usr/local/sphinx;
uwsgi_param UWSGI_SCRIPT webpytest;
}
注意:uwsgi_pass 的相关配置必须和启动uwsgi时的一致!UWSGI_CHDIR是指程序所在的目录,UWSGI_SCRIPT是指启动哪个程序(注意,这里必须去掉py后缀).测试发现,UWSGI_CHDIR 和UWSGI_SCRIPT也可以不要!
(6)启动nginx
/usr/local/nginx/sbin/nginx
重启nginx命令为(/usr/local/nginx/sbin/nginx -s stop)
遇到的问题: 1)提示找不到 libpcre.so.1
解决办法:如果是32位系统,ln -s /usr/local/lib/libpcre.so.1 /lib
如果是64位系统,ln -s /usr/local/lib/libpcre.so.1 /lib64
(7)通过http即可访问 http://10.0.11.226
以上只是一个非常简单的搭建过程,仅作记录!
来源:http://blog.ops.cc/hosting/22935dcc7d57e320.html
相关文章推荐
- Nginx + uWSGI + web.py 搭建示例
- centos7简单搭建nginx+uwsgi+web.py的Python web环境(记录)
- linux下搭建nginx+uwsgi+web.py的python web服务器
- Nginx+uwsgi+Django 搭建一个简单的web服务器
- nginx + uwsgi+web.py
- web.py运行于nginx的uwsgi上
- Nginx + webpy 和FastCGI搭建webpy环境 推荐
- Web.py Cookbook 简体中文版 - Webpy + Nginx with FastCGI搭建Web.py
- mac下安装nginx+uwsgi+webpy出错解决
- Windows下nginx+web.py+fastcgi服务搭建
- Cenots下nginx+uwsgi+web.py环境部署总结
- Webpy + Nginx with FastCGI搭建Web.py
- nginx+spawn-fcgi+flup+webpy服务搭建
- nginx+uwsgi+flask搭建python-web应用程序
- Nginx+uWSGI+Django+Python+ MySQL 搭建可靠的Python Web服务器
- nginx+uwsgi部署python web(web.py)
- nginx+uwsgi+web.py的部署
- Nginx+uwsgi+web.py
- Nginx+uWSGI+DJango+Python+ Mysql 搭建可靠的python web服务