Apache + mod_wsgi (Python)部署webpy应用

1. 搭建 Apache 服务器

  (1). 下载 Httpd 及依赖 -- apr、apr-util

    httpd : http://httpd.apache.org/

    apr & apr-util : https://apr.apache.org/

  (2). 编译 

    apr :
$ ./configure --prefix=/usr/local/apr
$ make & sudo make install

 

    apr-util : 
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make & sudo make install

 

    httpd :     
$ ./configure --prefix=/usr/local/apache2 \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--sysconfdir=/etc/ \
--enable-modules=all \
--enable-mpms-shared=all

$ make & sudo make install

 

2. 配置 wsgi 框架

  1. 下载mod_wsgi.so模块文件 : http://code.google.com/p/modwsgi

  2. 编译安装: 

$ ./configure --with-apxs=/usr/local/apache2/bin/apxs \
--with-python=/usr/bin/python

$ make & sudo make install

 

  3. 配置 httpd.conf 文件 : 

LoadModule wsgi_module modules/mod_wsgi.so

<IfModule wsgi_module>
    WSGIScriptAlias /webapp /var/www/webpy-app/code.py/

    Alias /webapp/static /var/www/webpy-app/static/
    AddType text/html .py

    <Directory /var/www/webpy-app/>
        AllowOverride all
        Options Indexes FollowSymLinks ExecCGI
        Order deny,allow
        SetHandler wsgi-script
        Allow from all
    </Directory>
</IfModule>

ServerName 127.0.1.1:80

PS : 将 Request 注释,如下 : 

<Directory />
    AllowOverride none
    # Require all denied
</Directory>

 

posted @ 2015-01-15 11:23  naray  阅读(492)  评论(0编辑  收藏  举报