After upgrade to jessie my django stops working. I found that problem is in mod_python, so I decided that this is good reason to migrate to mod_wsgi. I read this but i'm not sure what to do if i got more than one project:
I got few projects in /home folder:
my apache's http.conf (not migrated to 2.4 yet, so please ignore Order/allow etc)
<VirtualHost *:80>
ServerAdmin webmaster@mydomain.com
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>
I'm thinking about daemon mode, but how to use it on different projects???
Update According to @GrahamDumpleton's answer my new apache looks like:
ServerAdmin webmaster@mydomain.com
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>
Now it works - Thanks
Since your projects are all at separate sub URLs, simply use multiple WSGIScriptAlias
directives, one for each sub URL. And definitely use a daemon process group for each distinct Django instance.
For some additional reading see:
There are also the mod_wsgi docs, although they are in a slight mess right now.