不确定这里是否是提出这个问题的正确地方,但我正在将 django 项目从 mod_python 迁移到 mod_wsgi,并且我想确保我的 apache 配置正确。旧配置如下所示:
DocumentRoot /srv/www/PROJECT/
<location "/">
Options +FollowSymLinks
allow from all
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE PROJECT.settings
PythonPath "['/srv/www/PROJECT'] + sys.path"
PythonDebug On
PythonInterpreter PROJECT
</location>
<location "/site_media/">
Options +FollowSymLinks
SetHandler None
</location>
<location "/admin_media/">
Options +FollowSymLinks
SetHandler None
</location>
<Location "/server-status">
SetHandler server-status
Allow from .test.org localhost 127.0.0.1
</Location>
阅读文档,似乎我要做的就是:
WSGIDaemonProcess PROJECT processes=2 threads=15 display-name=%{GROUP}
WSGIProcessGroup PROJECT
WSGIScriptAlias /PROJECT /srv/www/django.wsgi
<Directory /srv/www/PROJECT/ >
Order allow,deny
Allow from all
</Directory>
Alias /site_media "/srv/www/site_media/"
Alias /admin_media "/srv/www/admin_media/"
django.wsgi 包含:
import os,sys
sys.path.append('/srv/www/PROJECT')
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
这些看起来是适当的更改吗?我对 mod_python 不太熟悉(我没有设置此站点 - 现在我的工作只是迁移它 :( )所以我不确定转换。任何其他建议都将不胜感激。