Deploying multiple django apps on Apache with mod_wsgi

前端 未结 3 1349
野趣味
野趣味 2020-12-04 16:47

I want to deploy two different django apps in the same host: The first will correspond to the url /site1 and the second to the url /site2. Here\'s my configuration:

3条回答
  •  离开以前
    2020-12-04 17:33

    This is a problem with the wsgi.py file generated by Django 1.4. It will not work where trying to host two distinct Django instances in the same process, even though in separate sub interpreters.

    Change:

    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "site1.settings")
    

    to:

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

    Or better still use daemon mode and delegate each to run in distinct daemon process groups.

    That is, instead of:

    WSGIScriptAlias /site1 /var/www/py/site1/site1/wsgi.py
    WSGIScriptAlias /site2 /var/www/py/site2/site2/wsgi.py
    
    WSGIPythonPath /var/www/py/site1:/var/www/py/site2
    

    use:

    WSGIDaemonProcess site1 python-path=/var/www/py/site1
    WSGIScriptAlias /site1 /var/www/py/site1/site1/wsgi.py process-group=site1 application-group=%{GLOBAL}
    
    WSGIDaemonProcess site2 python-path=/var/www/py/site2
    WSGIScriptAlias /site2 /var/www/py/site1/site2/wsgi.py process-group=site2 application-group=%{GLOBAL}
    

    UPDATE

    Note that there is a whole blog post about this and other causes now.

    • http://blog.dscpl.com.au/2012/10/requests-running-in-wrong-django.html

提交回复
热议问题