Multiple django instances on Apache Windows using the same virtual host

Viewed 17

I have a WAMP Server 3.2 (Apache 2.4.46) installed on Windows 10 (64-bits), it is exposed to the local company network. I need to deploy several django projects under the same host - the company network doesn't allow another ServerName. Is it possible at all? Daemon Processing is not an option since this is Windows.

My httpd-vhosts.conf:

<VirtualHost *:80>
    ServerName XXXXXXXXXXXX
    DocumentRoot "d:/projects"
    WSGIPassAuthorization On
    WSGIScriptAlias /site1  "d:\projects\site1\site1\wsgi_windows.py"
    WSGIScriptAlias /site2  "d:\projects\site2\site2\wsgi_windows.py"
    
    WSGIApplicationGroup %{GLOBAL}
    <Directory "d:\projects\site1\site1">
        <Files wsgi_windows.py>
            Options +Indexes +Includes +FollowSymLinks +MultiViews
            AllowOverride All
            Require all granted
        </Files>
    </Directory>
    <Directory "d:\projects\site2\site2">
        <Files wsgi_windows.py>
            Options +Indexes +Includes +FollowSymLinks +MultiViews
            AllowOverride All
            Require all granted
        </Files>
    </Directory>

    Alias /static "d:/projects/site1/static"
    <Directory "d:/projects/site1/static">
        Require all granted
    </Directory>  
</VirtualHost>

Example of wsgi_windows.py for site1:

activate_this = r'C:/Users/XXXXX/Envs/XXXXXX/Scripts/activate_this.py'
exec(open(activate_this).read(),dict(__file__=activate_this))

import os
import sys
import site

site.addsitedir(r'C:/Users/XXXXX/Envs/XXXXXX/Lib/site-packages')

sys.path.append(r'D:/Projects/site1')
sys.path.append(r'D:/Projects/site1/site1')

os.environ['DJANGO_SETTINGS_MODULE'] = 'site1.settings'

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Right now I have Apache running only site1. If I try to reach site2 I got a error 404 "Page is not found" and Django error page listing the available urls for site1 (I have DEBUG=True). Is it possible to get both site1 and site2 working?

0 Answers
Related