標籤:
一.安裝Mod_wsgi1.先yum -y install httpd-devel,否則會提示沒有apxs2.如果在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.so4.安裝web.py二、部署web.py網站1.將網站拷貝到/var/www/html中,網站名稱WebpyTest2.修改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
apache 部署web.py