首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在同一IP的不同虚拟环境中为多个Django项目提供服务(Apache)

在同一IP的不同虚拟环境中为多个Django项目提供服务(Apache)
EN

Stack Overflow用户
提问于 2018-06-09 18:31:29
回答 1查看 224关注 0票数 0

我试图在Apache的同一IP地址上为不同的virtualenv上的两个Django项目提供服务。

我的第一个网站是http://myip/site-1,第二个是:http://myip/site-2

当我运行http://myip/site-1时,Apache为它服务时没有问题,但当我运行第二个(http://myip/site-2)时,它引发了以下问题:

代码语言:javascript
复制
The requested URL /site-2/ was not found on this server.

因为它在第一个站点的文档根目录中进行搜索。

这是我的apache.conf

代码语言:javascript
复制
<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>

我尝试了许多我在网上找到的解决方案,但问题仍然是一样的。

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-06-09 18:52:56

您必须连接到http://site-1.example.com (使用示例中的术语),而不是http://myip/site-1。还有http://site-2.example.com而不是http://myip/site-2

一般来说,您可以使用需要配置DNS的name-based virtual hosts (将site-1.example.comsite-2.example.com映射到您的IP地址),也可以使用run different sites on different ports

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50773316

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档