在apache上运行不同的virtualenv中的多个django项目

Ash*_*pta 7 apache django virtualhost

我想在不同的virtualenv中运行两个不同的django_projects.这是代码:

ServerName ubuntu_server_apache

<VirtualHost *:80>

ServerName dev.hexxie.com

ErrorLog "/home/ashish/deployments/mysite_dev/conf/mysite_dev_error.log"

WSGIScriptAlias / /home/ashish/deployments/mysite_dev/mysite/mysite/wsgi.py

Alias /static /home/ashish/deployments/mysite_dev/static_root
<Directory /home/ashish/deployments/mysite_dev/static_root>
Require all granted
</Directory>

Alias /media /home/ashish/deployments/mysite_prod/data/media
<Directory /home/ashish/deployments/mysite_prod/data/media>
Require all granted
</Directory>

<Directory /home/ashish/deployments/mysite_dev/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

</VirtualHost>
WSGIPythonPath /home/ashish/deployments/mysite_dev/mysite:/home/ashish/.virtualenvs/mysite_dev/lib/python2.7/site-packages



<VirtualHost *:80>

ServerName hexxie.com
ServerAlias *.hexxie.com

ErrorLog "/home/ashish/deployments/mysite_prod/conf/mysite_error.log"

WSGIScriptAlias / /home/ashish/deployments/mysite_prod/mysite/mysite/wsgi.py

Alias /static /home/ashish/deployments/mysite_prod/static_root
<Directory /home/ashish/deployments/mysite_prod/static_root>
Require all granted
</Directory>

Alias /media /home/ashish/deployments/mysite_prod/data/media
<Directory /home/ashish/deployments/mysite_prod/data/media>
Require all granted
</Directory>

<Directory /home/ashish/deployments/mysite_prod/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

</VirtualHost>
WSGIPythonPath /home/ashish/deployments/mysite_prod/mysite:/home/ashish/.virtualenvs/mysite_prod/lib/python2.7/site-packages
Run Code Online (Sandbox Code Playgroud)

但是我使用这个apache conf得到了内部服务器错误.我觉得这是因为WSGIPythonPath在conf中使用了两次.WSGIPythonPath不能包含在virtualhost中.那么如何在Apache上的diff virtualenv上运行两个diff django项目呢?

Gra*_*ton 4

首先,使用守护进程进程组,以便每个进程在单独的进程中运行,然后python-home在相应的WSGIDaemonProcess组指令上使用该选项。看: