Multiple Django applications using virtualenv on Apache 2 on Ubuntu 11

我的未来我决定 提交于 2019-12-10 14:34:57

问题


I've successfully setup one Django application using virtualenv on Ubuntu and Apache 2, using the WSGIPythonHome directive pointing to my virtualenv location. Now I am in need to create a separate Django application, that is going to run on Apache on a different port on the same Ubuntu server. I am wondering if there's a way to have Apache run multiple WSGIPythonHome instances? Currently with WSGIPythonHome being set to one virtualenv root, there's a problem with imports on the second Django app…


回答1:


The best way to do this, I've discovered about a year ago, is to use WSGI as a daemon and set the python path in the daemon directive. Example is below

<VirtualHost *:80>
    ServerName yourhost.com

    <Directory />
      Order deny,allow
      #Require all granted
    </Directory>

    #Alias /static /opt/yourhost/static
    WSGIScriptAlias / /opt/yourhost/wsgi.py

    WSGIApplicationGroup %{GLOBAL}

    WSGIDaemonProcess yourhost.com python-path=/opt/yourhost:/opt/yourhost/venv/lib/python2.7/site-packages processes=2 threads=15 display-name=%{GROUP}
    WSGIProcessGroup  yourhost.com
</VirtualHost>
WSGISocketPrefix /var/run/wsgi



回答2:


You should do this with separate virtual hosts in Apache. Each one can listen to a particular port, and can have its own separate WSGI directives.



来源:https://stackoverflow.com/questions/9991461/multiple-django-applications-using-virtualenv-on-apache-2-on-ubuntu-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!