[Solved]-Two Django projects running simultaneously and mod_wsgi acting werid

14πŸ‘

βœ…

Use this as a workaround:

WSGIDaemonProcess pydaemon-1 processes=1 threads=5
WSGIDaemonProcess pydaemon-2 processes=1 threads=5

WSGIScriptAlias /test /var/www/html/test/wsgi.py

<Location /test>
WSGIProcessGroup pydaemon-1
WSGIApplicationGroup %{GLOBAL}
</Location>

WSGIScriptAlias /proto /var/www/html/proto/wsgi.py

<Location /proto>
WSGIProcessGroup pydaemon-2
WSGIApplicationGroup %{GLOBAL}
</Location>

This will force each application into separate daemon process group and no way they should be able to interfere with each other.

If that still doesn’t work, you have problems with your WSGI script file somehow.

4πŸ‘

I also have 2 Django projects however each one is running on a different port (httpd config), it looks something like this:

<VirtualHost *:80>
    ServerAdmin xx
    ServerName xx
    ServerAlias xx
    ErrorLog /path/to/first/project/logs/error.log
    CustomLog /path/to/first/project/logs/access.log combined

    Alias /static/ /path/to/first/project/sitestatic

    WSGIDaemonProcess app processes=1 threads=15 display-name=%{GROUP}
    WSGIProcessGroup app

    WSGIScriptAlias / /path/to/first/project/django.wsgi

    <Directory /path/to/first/project/apache>
       Order deny,allow
       Allow from all
     </Directory>
</VirtualHost>

<VirtualHost *:8080>
    ServerAdmin xx
    ServerName xx
    ServerAlias xx
    ErrorLog /path/to/second/project/logs/error.log
    CustomLog /path/to/second/project/logs/access.log combined

    WSGIDaemonProcess app1 processes=1 threads=15 display-name=%{GROUP}
    WSGIProcessGroup app1

    WSGIScriptAlias / /path/to/second/project/apache/django.wsgi

     <Directory /path/to/second/project/apache>
         Order deny,allow
         Allow from all
     </Directory>
</VirtualHost>
πŸ‘€Ali

1πŸ‘

The problem might be related to Apache sharing the Python sub interpreter between WSGI applications. Try adding this to the Apache configuration to avoid sharing:

WSGIApplicationGroup %{GLOBAL}

Check this blog post for in-depth explanation and additional tips (check the comments too).

πŸ‘€Lycha

0πŸ‘

Can’t comment on the answer given by Graham, so adding one of my own.

The problem for me really was the Python Interpreter, but I also had to add the python-path for each interpreter. Here follows an example configuration:

WSGIDaemonProcess py_app1 processes=1 threads=5 python-path=/path/to/app1
WSGIScriptAlias /app1 /path/to/app1/wsgi.py
<Directory /path/to/app1>
    <Files wsgi.py>
        Order deny,allow
        Allow from all
    </Files>
</Directory>
<Location /app1>
    WSGIProcessGroup py_app1
    WSGIApplicationGroup %{GLOBAL}
</Location>

WSGIDaemonProcess py_app2 processes=1 threads=5 python-path=/path/to/app2
WSGIScriptAlias /app2 /path/to/app2/wsgi.py
<Directory /path/to/app2>
    <Files wsgi.py>
        Order deny,allow
        Allow from all
    </Files>
</Directory>
<Location /app2>
    WSGIProcessGroup py_app2
    WSGIApplicationGroup %{GLOBAL}
</Location>
πŸ‘€Pedro Walter

Leave a comment