Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two separate django sites in WSGI (root and /two)

After hours of trying I've decided to give in and ask SO for help :)

I have two Django 1.6 sites running on Apache2 on Debian 7. I have one vhost.

I want the root domain for the vhost to go to one django site (example: mydomain.com), and a separate alias for the second site (example: mydomain.com/two).

I can get two alias to work like below:

    WSGIDaemonProcess test1 python-path=/usr/local/projects/project_one:/usr/local/virtualenvs/project/lib/python2.7/site-packages
    WSGIScriptAlias /one /usr/local/projects/project_one/project_one/wsgi.py
    <Location /one>
            WSGIProcessGroup test1
    </Location>

    WSGIDaemonProcess test2 python-path=/usr/local/projects/project_two:/usr/local/virtualenvs/project/lib/python2.7/site-packages
    WSGIScriptAlias /two /usr/local/projects/project_two/project_two/wsgi.py
    <Location /two>
            WSGIProcessGroup test2
    </Location>

This will work if I use the following domains:

http://mydomain.com/one/

http://mydomain.com/two/

But if I want to use the root (mydomain.com) and another (mydomain.com/two), it will not work:

    WSGIDaemonProcess test1 python-path=/usr/local/projects/project_one:/usr/local/virtualenvs/project/lib/python2.7/site-packages
    WSGIScriptAlias / /usr/local/projects/project_one/project_one/wsgi.py
    <Location />
            WSGIProcessGroup test1
    </Location>

    WSGIDaemonProcess test2 python-path=/usr/local/projects/project_two:/usr/local/virtualenvs/project/lib/python2.7/site-packages
    WSGIScriptAlias /two /usr/local/projects/project_two/project_two/wsgi.py
    <Location /two>
            WSGIProcessGroup test2
    </Location>

I believe it is not working because it's trying to run site one with site two's WSGI file: WSGI script '/usr/local/projects/project_one/project/wsgi.py'.

My question is how can I get the second attempt to work so mydomain.com goes to one project, and mydomain.com/two goes to another....

I originally followed this post to get to where I am, but not been able to find anything to help me get round this roadblock.

Appreciate the support, Mark

like image 774
LondonAppDev Avatar asked Oct 01 '22 22:10

LondonAppDev


1 Answers

Try add the options "process-group" and "application-group" in the WSGIScriptAlias directive:

WSGIScriptAlias / /usr/local/projects/project_one/project_one/wsgi.py process-group=test1 application-group=%{GLOBAL}

...

WSGIScriptAlias /two /usr/local/projects/project_two/project_two/wsgi.py process-group=test2 application-group=%{GLOBAL}

like image 83
Dilvane Zanardine Avatar answered Oct 06 '22 02:10

Dilvane Zanardine