gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 09:23:55 25 4
gpt4 key购买 nike

我想在不同的 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

但是我使用此 apache conf 收到内部服务器错误。我觉得这是由于 WSGIPythonPath 在conf中使用了两次。 WSGIPythonPath 不能包含在虚拟主机内。那么如何在 apache 上的 diff virtualenv 上分别运行两个 diff django 项目呢?

最佳答案

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

关于django - 在apache上的不同virtualenv中运行多个django项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30584505/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com