Apache Python wsgi
时间:2010-03-01 来源:jack_sir
在Ubuntu下安装:
Linux 命令- sudo apt-get install libapache2-mod-wsgi
安装成功后:检查 /etc/apache2/mods-enabled 应该有 wsgi.load 文件
wsgi.load 文件内容- LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so
下面是配置使之支持Django
在project目录下建立一个文件 mod.wsgi 名字随意
我的目录是 : /var/www/Django/testing
mod.wsgi 文件内容:
Python代码- import os, sys
- sys.path.append('/var/www/Django')
- os.environ['DJANGO_SETTINGS_MODULE'] = 'testing.settings'
- import django.core.handlers.wsgi
- application = django.core.handlers.wsgi.WSGIHandler()
再来配置 apache2.conf文件
XML/HTML代码- <Directory /var/www/Django/testings/>
- Order deny,allow
- Allow from all
- </Directory>
- WSGIScriptAlias / '/var/www/Django/testing/mod.wsgi'
打开 http://localhost 就可以看到的你项目
如果是要用虚拟目录则这样这样修改
XML/HTML代码- <Directory /var/www/Django/testings/>
- Order deny,allow
- Allow from all
- </Directory>
- WSGIScriptAlias /wsgi-testing '/var/www/Django/testing/mod.wsgi'
那么,地址就变成 http://localhost/wsgi-testing
httpd.conf配置示列:
<Directory /usr/share/moin/>
AllowOverride AuthConfig
AuthName "moinmoin"
AuthType Basic
AuthUserFile /usr/local/apache2/passwd.user
require valid-user
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias / /usr/share/moin/moin.wsgi
WSGIDaemonProcess moin user=daemon group=daemon processes=5 threads=10 maximum-requests=1000 umask=0007
WSGIProcessGroup moin