在Ubuntu 11上使用Apache2上的virtualenv的多个Django应用程序 [英] Multiple Django applications using virtualenv on Apache 2 on Ubuntu 11
问题描述
在Ubuntu和Apache 2上,我已经使用 virtualenv
成功设置了一个Django应用程序,使用 WSGIPythonHome
指令到我的 virtualenv
位置。现在我需要创建一个单独的Django应用程序,这将在同一个Ubuntu服务器上的另一个端口上的Apache上运行。我想知道有没有办法让Apache运行多个 WSGIPythonHome
实例?目前使用 WSGIPythonHome
设置为一个 virtualenv
根目录,导致第二个Django应用程序出现问题...
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…
推荐答案
我发现大约一年前的最佳方式是使用WSGI作为守护进程,并设置python路径在守护程序指令中。例如在
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
这篇关于在Ubuntu 11上使用Apache2上的virtualenv的多个Django应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!