0
升级到jessie后,我的django停止工作。我发现这个问题在mod_python中,所以我决定这是迁移到mod_wsgi的很好的理由。 我读this但我不知道该怎么办,如果我有一个以上的项目:从mod_python迁移到mod_wsgi(多个项目)
我在/ home文件夹了几个项目:
- /家庭/ PROJECT1
- /家/项目2
- /家庭/项目3
我的apache的http.conf中(未迁移至2.4还,所以请无视订单/允许等)
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Location "/project1">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE project1.settings
PythonInterpreter project1
PythonOption django.root /project1
PythonDebug On
PythonPath "['/home', '/home/project1'] + sys.path"
</Location>
<Location "/project2">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE project2.settings
PythonInterpreter project2
PythonOption django.root /project2
PythonDebug On
PythonPath "['/home', '/home/project2'] + sys.path"
</Location>
<Location "/project3">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE project3.settings
PythonInterpreter project3
PythonOption django.root /project3
PythonDebug On
PythonPath "['/home', '/home/project3'] + sys.path"
</Location>
Alias /admin_media/ /usr/share/pyshared/django/contrib/admin/media/
Alias /static/ /home/common/
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
我在考虑守护进程模式,但如何在不同的项目上使用它?
更新 据@ GrahamDumpleton的回答我的新的Apache看起来像:
的ServerAdmin [email protected]
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Require all granted
</Directory>
WSGIDaemonProcess project1
WSGIDaemonProcess project2
WSGIDaemonProcess project3
WSGIScriptAlias /project1/ /home/project1/wsgi.py process-group=project1
WSGIScriptAlias /project2/ /home/project2/wsgi.py process-group=project2
WSGIScriptAlias /project3/ /home/project3/wsgi.py process-group=project3
<Directory /home/*>
Require all granted
</Directory>
Alias /admin_media/ /usr/share/pyshared/django/contrib/admin/media/
Alias /static/ /home/common/
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
现在,它的工作原理 - 感谢
WSGIApplicationGroup?对我无用吗? –
如果对所有东西都使用WSGIScriptAlias,并且总是使用“process-group”选项,那么是的,不需要WSGIProcessGroup,因为“process-group”选项优先于那个WSGI应用程序。顺便说一句,因为你有每个在它自己的守护进程组,所以也在最后加上''application-group =%{GLOBAL}''到''WSGIScriptAlias''。这将确保使用各个进程的主要解释器上下文,从而避免某些第三方Python模块在子解释器中不起作用的问题。 –