skip to Main Content

I am using mod_wsgi in a virtualenv with Apache 2.4 and I want to serve multiple Django sites from the same server.

httpd.config

### Configuration Site_1
LoadModule wsgi_module " S:/Site_1/VirtualEnvSite_1/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win_amd64.pyd"
WSGIApplicationGroup %{GLOBAL}
WSGIPythonHome "c:/users/mmyuser/appdata/local/programs/python/python36"
WSGIScriptAlias / " S:/Site_1/site_1/site_1/wsgi_windows.py"
WSGIPythonPath " S:/Site_1/VirtualEnvSite_1/Lib/site-packages"

Alias /static " S:/Site_1/site_1/staticfiles"
Alias /media " S:/Site_1/site_1/media"

<Directory " S:/Site_1/site_1/staticfiles">
    Require all granted
</Directory>

<Directory " S:/Site_1/site_1/media">
    Require all granted
</Directory>

<Directory " S:/Site_1/site_1/PEQ">
    <Files wsgi_windows.py>
        Require all granted
    </Files>
</Directory>

####Configuration Site_2
LoadModule wsgi_module " S:/Site_2/VirtualEnvSite_2/lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win_amd64.pyd"
WSGIApplicationGroup %{GLOBAL}
WSGIPythonHome "c:/users/myuser/appdata/local/programs/python/python36"
WSGIScriptAlias / " S:/Site_2/site_2/site_2/wsgi_windows.py"
WSGIPythonPath " S:/Site_2/VirtualEnvSite_2/Lib/site-packages"

Alias /static " S:/Site_2/site_2/staticfiles"
Alias /media " S:/Site_2/site_2/media"

<Directory " S:/Site_2/site_2/staticfiles">
    Require all granted
</Directory>

<Directory " S:/Site_2/site_2/media">
    Require all granted
</Directory>

<Directory " S:/Site_2/site_2/site_2">
    <Files wsgi_windows.py>
        Require all granted
    </Files>
</Directory>

httpd-vhosts.config

# Virtual Hosts
#
<VirtualHost *:8080>
    ServerAdmin webmaster@localhost
    DocumentRoot "c:/wamp/www"
    ServerName localhost
    ErrorLog "logs/localhost-error.log"
    CustomLog "logs/localhost-access.log" common
</VirtualHost>

I have reviewed these posts:

  1. Deploying multiple django apps on Apache with mod_wsgi
  2. multiple-django-sites-with-apache-mod-wsgi
  3. running-multiple-django-projects-on-one-apache-instance-with-mod_wsgi/
  4. MĂșltiples direcciones, un solo proyecto
  5. how-to-use-mod-wsgi-for-hosting-multiple-django-projects-under-single-domain

but they have not worked for me.

The server is a Windows Server 2012R2

Please direct me what I should do to get both sites up and running.

Note: The websites work perfectly separate

2

Answers


  1. I also have a similar problem. And I’ve already looked for many posts, one thing I noticed different from yours was the line:

    WSGIScriptAlias / " S:/Site_1/site_1/site_1/wsgi_windows.py"
    WSGIScriptAlias / " S:/Site_2/site_2/site_2/wsgi_windows.py"
    

    I identify the site in the alias:

    WSGIScriptAlias /site1 " S:/Site_1/site_1/site_1/wsgi_windows.py"
    WSGIScriptAlias /site2 " S:/Site_2/site_2/site_2/wsgi_windows.py"
    

    And I’m using process daemon:

    WSGIScriptAlias /site1 /site1/wsgi.py
    WSGIDaemonProcess site1_proc python-path=S:/Site_1/VirtualEnvSite_1/Lib/site-packages python-home="c:/users/mmyuser/appdata/local/programs/python/python36"
    WSGIProcessGroup site1_proc 
    

    In my case it’s still not working for some other reason. Which I haven’t identified yet. Individual applications run correctly using reverse proxy. But when I activate both, one of them gives the error: AH00128: File does not exist: /var/www/html/myapp2/. Configuration files are identical.

    Login or Signup to reply.
  2. Here are my config for setting up multiple projects apache | windows | wsgi

    httpd.conf

    LoadFile "c:/python37/python37.dll"
    LoadModule wsgi_module "c:/python37/lib/site-packages/mod_wsgi/server/mod_wsgi.cp37-win_amd64.pyd"
    WSGIPythonHome "c:/python37"
    
    # site 1 config
    WSGIScriptAlias /site1 "C:/Payslips/payslips_app/wsgi.py" application-group=site1
    
    <Directory "C:/Payslips/payslips_app/">
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>
    
    Alias /static "C:/Payslips/static/"
    <Directory "C:/Payslips/static/">
        Require all granted
    </Directory>
    
    # site 2 config
    WSGIScriptAlias /site2 "C:/Subsistance-Payments-System/subsistance_payment/wsgi.py" application-group=site2
    
    <Directory "C:/Subsistance-Payments-System/subsistance_payment/">
        <Files wsgi.py>
            Require all granted
        </Files>
    </Directory>
    

    site1 wsgi.py

    import os
    import sys
    from django.core.wsgi import get_wsgi_application
    
    sys.path.append('C:/Payslips/')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'payslips_app.settings'
    application = get_wsgi_application()
    

    site2 wsgi.py

    import os
    import sys
    from django.core.wsgi import get_wsgi_application
    
    sys.path.append('C:/Subsistance-Payments-System/')
    os.environ['DJANGO_SETTINGS_MODULE'] = 'subsistance_payment.settings'
    application = get_wsgi_application()
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search