nidhin nidhin - 1 year ago 105
Apache Configuration Question

how can I deploy multiple django cms projects under same domain.I am using apache 2.2 and mod_wsgi

I need to deploy two Django Cms projects under the same domain name. I need to retrieve the two sites when calling the following domain.
http://rndbkw.tk
http://rndbkw.tk/blog

I have two wsgi configurations included in the httpd.conf

for http://rndbkw.tk

ServerName rndbkw.tk
WSGIDaemonProcess rnd python-path=/home/rndbkw/djangocms:/home/rndbkw/virtualenv2.7/lib/python2.7/site-packages/
WSGIProcessGroup rnd
WSGIScriptAlias / /home/rndbkw/djangocms/rnd/wsgi.py

ServerName rndbkw.tk
WSGIDaemonProcess blog python-path=/home/rndbkw/projects/djangocms:/home/rndbkw/projects/virtualenv2.7/lib/python2.7/site-packages/
WSGIProcessGroup blog
WSGIScriptAlias / /home/rndbkw/projects/djangocms/rnd/wsgi.py


But i cannot get back http://rndbkw.tk/blog

Answer Source

You have a few problems with your configuration of:

ServerName rndbkw.tk
WSGIDaemonProcess rnd python-path=/home/rndbkw/djangocms:/home/rndbkw/virtualenv2.7/lib/python2.7/site-packages/
WSGIProcessGroup rnd
WSGIScriptAlias / /home/rndbkw/djangocms/rnd/wsgi.py

ServerName rndbkw.tk
WSGIDaemonProcess blog python-path=/home/rndbkw/projects/djangocms:/home/rndbkw/projects/virtualenv2.7/lib/python2.7/site-packages/
WSGIProcessGroup blog
WSGIScriptAlias / /home/rndbkw/projects/djangocms/rnd/wsgi.py

Instead use:

ServerName rndbkw.tk

WSGIDaemonProcess blog python-home=/home/rndbkw/projects/virtualenv2.7 python-path=/home/rndbkw/projects/djangocms
WSGIScriptAlias /blog /home/rndbkw/projects/djangocms/rnd/wsgi.py process-group=blog application-group=%{GLOBAL}

WSGIDaemonProcess rnd python-home=/home/rndbkw/virtualenv2.7 python-path=/home/rndbkw/djangocms
WSGIScriptAlias / /home/rndbkw/djangocms/rnd/wsgi.py process-group=rnd application-group=%{GLOBAL}

Changes made were:

  • Mount blog at sub URL of /blog.
  • Move the WSGIScriptAlias for /blog before that for / so that it takes precedence, else that for / will always match first and nothing will ever get through the the blog site.
  • Per best practice, use python-home of WSGIDaemonProcess directive to specify the location of the virtual environment instead of adding site-packages using python-path.
  • Use process-group option to WSGIScriptAlias to indicate which daemon process group to use. This makes it more precise. Your use of WSGIProcessGroup wouldn't have worked as wasn't qualified to a Location or Directory scope so whichever of the two WSGIProcessGroup directives was last would have overridden the first.
  • Set application-groupto %{GLOBAL} to force use of main interpreter context of each daemon process. This solves problems with some third party extension modules for Python that will not work in sub interpreter contexts.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download