![](/img/trans.png)
[英]Can I have multiple django projects in the same virtualenv folder
[英]Serving multiple Django projects in different virtualenv at the same IP (Apache)
我正在嘗試在Apache上以相同IP地址在不同virtualenv上提供兩個Django項目。
我的第一個站點位於http:// myip / site-1 ,第二個站點位於http:// myip / site-2
當我運行http:// myip / site-1時 ,Apache會毫無問題地運行它,但是當我運行第二個http:// myip / site-2時,它將引發以下問題:
The requested URL /site-2/ was not found on this server.
因為它在第一個站點的文檔根目錄中搜索。
這是我的apache.conf
<VirtualHost *:80>
ServerName site-1.example.com
DocumentRoot /home/venv/site-1
# adjust the following line to match your Python path
WSGIDaemonProcess site-1.example.com processes=2 threads=15 display-name=%{GROUP} python-home=/home/venv/lib/python2.7
WSGIProcessGroup site-1.example.com
WSGIScriptAlias / /home/venv/site-1/site-1/wsgi.py
<directory /home/venv/site-1>
AllowOverride all
Require all granted
Options FollowSymlinks
</directory>
Alias /static/ /home/venv/site-1/static_root/
<Directory /home/venv/site-1/static_root>
AllowOverride all
Require all granted
Options FollowSymlinks
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName site-2.example.com
DocumentRoot /home/venv_mob/site-2
# adjust the following line to match your Python path
WSGIDaemonProcess site-2.example.com processes=2 threads=15 display-name=%{GROUP} python-home=/home/venv_mob/lib/python2.7
WSGIProcessGroup site-2.example.com
WSGIScriptAlias / /home/venv_mob/site-2/site-2/wsgi.py
<directory /home/venv_mob/site-2>
AllowOverride all
Require all granted
Options FollowSymlinks
</directory>
Alias /static/ /home/venv_mob/site-2/static_root/
<Directory /home/venv_mob/site-2/static_root>
AllowOverride all
Require all granted
Options FollowSymlinks
</Directory>
</VirtualHost>
我嘗試了很多在網上找到的解決方案,但問題仍然存在。
有任何想法嗎 ?
您必須連接到http://site-1.example.com
(使用示例中的術語),而不是http://myip/site-1
。 還有http://site-2.example.com
,而不是http://myip/site-2
。
一般來說,您可以具有基於名稱的虛擬主機 ,您需要為其配置DNS(將site-1.example.com
和site-2.example.com
映射到您的IP地址),或者可以在不同的端口上運行不同的站點 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.