Two Django projects running simultaneously and mod_wsgi acting werid

前端 未结 4 876
轻奢々
轻奢々 2020-12-09 12:21

I\'m trying to run two Django projects simultaneously. I happened to be using mod_wsgi, and found the site is acting weird. Perhaps there would be a workaround, but I\'d lik

相关标签:
4条回答
  • 2020-12-09 12:32

    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>
    
    0 讨论(0)
  • 2020-12-09 12:36

    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>
    
    0 讨论(0)
  • 2020-12-09 12:44

    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).

    0 讨论(0)
  • 2020-12-09 12:48

    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.

    0 讨论(0)
提交回复
热议问题