python web环境配置 ubuntu web.py apache mod_wsgi

 安装mod-wsgi 
   sudo apt-get install libapache2-mod-wsgi

/etc/apache2/sites-enabled  添加站点配置文件

#WSGISocketPrefix /var/run/apache2/wsgi
<VirtualHost *:80>
    ServerName webapp.com
    DocumentRoot /home/xxx/www/webapp
    <Directory /home/xxx/www/webapp>
        Order allow,deny
        Allow from all
    </Directory>
    Alias /static /home/xxx/www/webapp/static
    Alias /favicon.ico /home/xxx/www/webapp/static
    WSGIDaemonProcess webapp.com processes=2 threads=15 display-name=%{GROUP}
    WSGIProcessGroup webapp.com
    WSGIScriptAlias / /home/xxx/www/webapp/code.py
</VirtualHost>

在站点文件夹 /home/xxx/www/webapp/ 下创建  code.py

照搬文档的内容可能会出现 路径加载错误 

在最上方加入以下内容  问题解决

import sys, os
abspath = os.path.dirname(__file__)
sys.path.append(abspath)
os.chdir(abspath)

参考资料:

http://www.cnblogs.com/smallcoderhujin/p/3655662.html

http://blog.csdn.net/limisky/article/details/17298621


你可能感兴趣的:(apache,python,ubuntu,web.py,mod_wsgi,web环境配置)