apache 部署web.py

一.安装Mod_wsgi
1.先yum -y install httpd-devel,否则会提示没有apxs
2.如果在make时 wsgi报错apxs:Error: Command failed with rc=65536,那要在configure时加上--with-python=xxxx这个参数
3.解压Mod_wsgi
如果自定义升级过了python到2.7
#./configure --with-apxs=/usr/sbin/apxs --with-python=/usr/local/python27/bin/python2.7
如果是默认python:
#./configure --with-apxs=/usr/sbin/apxs --with-python=/usr/bin/python2.6
#make
#make install
根据提示执行#chmod 755 /usr/lib64/httpd/modules/mod_wsgi.so
4.安装web.py
二、部署web.py站点
1.将站点拷贝到/var/www/html中,站点名称WebpyTest
2.修改httpd.conf
#vi /etc/httpd/conf/httpd.conf,在末尾加入
 
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias /WebpyTest /var/www/html/WebpyTest/Code.py/
Alias /appname/static /var/www/webpy-app/static/   #没的话可以不加
AddType text/html .py
<Directory /var/www/html/Webpytest/>
    Order deny,allow
    Allow from all
</Directory>
 
3.修改Code.py
在定义class上方加上:application = web.application(urls, globals()).wsgifunc()
同时“if __name__ == '__main__':”这段代码可以删除
 
注意:
1.引用模版的路径,最好加上是
render = web.template.render(os.getcwd()+"/templates/")
 
这样能获取完整的路径
 

参考:http://webpy.org/cookbook/mod_wsgi-apache.zh-cn

附件:

https://app.yinxiang.com/shard/s41/res/6b8ce786-62eb-46de-8fb4-4a09e0f594b8/web.py-0.37.tar.gz

转载于:https://www.cnblogs.com/biboxie/p/4233381.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值