【问题标题】:VirtualHost for django site on dedicated server with multiple web sitesVirtualHost for django 站点在具有多个网站的专用服务器上
【发布时间】:2014-03-03 21:58:15
【问题描述】:

所以,我正在尝试在我的专用服务器上运行 Django 网站,该服务器本身有多个站点,其文件夹结构如下所示:

home/user/www/
              site1/
              site2/
              site3/
              mydjangosite.com/

site1、site2 等是 php/html 网站,当然我需要让它们保持运行,所以我想知道我应该如何配置我的 httpd.conf,因为下面的这些行不起作用:

<VirtualHost *:80>
    DocumentRoot home/user/www/mydjangosite.com
    ServerName mydjangosite
    WSGIScriptAlias / home/user/www/mydjangosite.com/testing/wsgi.py
    <Directory "home/user/www/mydjangosite.com/testing">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

编辑

我已经修改了我的 httpd.conf,而不是上面的行(使用 VirtualHost *:80)我添加了下一个:

WSGIScriptAlias / /home/user/www/mydjangosite.com/testing/wsgi.py
WSGIPythonPath /home/user/www/mydjangosite.com
<Directory /home/user/www/mydjangosite.com/testing>
    <Files wsgi.py>
    Order deny,allow
    Allow from all
    </Files>
</Directory>

最后我得到了 Django 成功页面:

It worked!
Congratulations on your first Django-powered page.

但是现在我得到了我服务器上每个域的 Django 页面。

【问题讨论】:

  • 定义不工作。很难猜。
  • “不工作”是指当我访问我的网站位置时,我没有从服务器得到任何响应。事实上,当我写信给 Somantra 的回复时,我只得到“默认网站页面”(就像没有默认索引页面(实际上没有)。Apache 错误日志说:“选项指令禁止的目录索引:/主页/****/www/mydjangosite.com/

标签: django apache mod-wsgi rhel


【解决方案1】:

试试这个:

<VirtualHost *:80>
    DocumentRoot /home/user/www/mydjangosite.com
    ServerName mydjangosite
    WSGIScriptAlias / /home/user/www/mydjangosite.com/testing/wsgi.py
    <Directory "/home/user/www/mydjangosite.com/testing">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

代替:

<VirtualHost *:80>
    DocumentRoot home/user/www/mydjangosite.com
    ServerName mydjangosite
    WSGIScriptAlias / home/user/www/mydjangosite.com/testing/wsgi.py
    <Directory "home/user/www/mydjangosite.com/testing">
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

【讨论】:

  • 感谢您的帮助,但这并没有解决我的问题:(
  • @LjubisaLivac,我仔细看了看,似乎 DocumentRoot 和 WSGIScriptAlias 节点有类似的错字。一定要更新这些。
  • 还是什么都没有……我已经添加了 WSGIScriptAlias / /home/user/www/mydjangosite.com/testing/wsgi.py (/ 表示根 url),但这也没有帮助跨度>
  • 你看到了什么 404?
  • 该错误表明运行 Apache 的用户无法访问您指向的目录。这通常是因为除了该主目录的所有者之外,任何人都无法读取主目录。不要将东西放在用户帐户的主目录下,或者以其他方式将主目录和其下的任何其他目录的权限更改为您的应用程序文件所在的位置,以便 Apache 用户可以访问/读取它们。
猜你喜欢
  • 2013-12-02
  • 1970-01-01
  • 1970-01-01
  • 2014-02-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-31
相关资源
最近更新 更多