apache+wsgi+web.py部署

软件:

安装apache:

# yum install httpd httpd-devel -y

安装mod_wsgi:

# tar xvf mod_wsgi-3.4.tar.gz
# cd mod_wsgi-3.4
# ./configure --with-apxs=/usr/sbin/apxs --with-python=/usr/bin/python
# make && make install

安装web.py:

# tar xvf web.py-0.37.tar.gz
# cd web.py-0.37
# python setup.py install

配置apache:

vim /etc/http/conf/httpd.conf

LoadModule wsgi_module modules/mod_wsgi.so
 
 
# wsgi 3.3
WSGIScriptAlias /appname        /var/www/webpy-app/code.py/
Alias   /appname/static /var/www/webpy-app/static/
AddType text/html       .py
 
<Directory /var/www/webpy-app>
        Order deny,allow
        Allow from all
</Directory>

重启apache:
# /etc/init.d/httpd restart
# mkdir -p /var/www/webpy-app/
# vim /var/www/webpy-app/code.py

在 /var/www/webpy-app/code.py 测试文件

#!/usr/bin/python
import web
 
  urls = (
      '/.*', 'hello',
      )
 
  class hello:
      def GET(self):
          return "Hello, world."
 
  application = web.application(urls, globals()).wsgifunc()

给code.py 加上执行权限
# chmod a+x code.py

然后在浏览器测试 http://localhost/appname