【问题标题】:Apache mod_wsgi instructions not being used未使用 Apache mod_wsgi 指令
【发布时间】:2011-04-05 17:25:26
【问题描述】:

我有一台运行 Ubuntu Lucid 10.04.1 LTS 服务器版的服务器,我想在使用 Apache + mod_wsgi 上部署一个 Django 应用程序。目前 Apache 做一个目录索引而不是使用我的 WSGIScriptAlias 命令。

任何提示为什么将不胜感激。我通过 aptitude 安装了 mod_wsgi,并假设下面的“模块配置”会加载它。

/etc/apache2/apache2.conf

#....

# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf

# Include all the user configurations:
Include /etc/apache2/httpd.conf

# Include ports listing
Include /etc/apache2/ports.conf

#....

# Include generic snippets of statements
Include /etc/apache2/conf.d/

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/

在站点启用中有两个文件,000-default-backup 和我的。

000-默认备份

<VirtualHost *:80>
    DocumentRoot /var/www/
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>
</VirtualHost>

我的

<VirtualHost *:80>
    WSGIDaemonProcess project-production user=me group=me threads=10 python-path=/home/me/virtualenvs/project/lib/python2.6/site-packages

    WSGIScriptAlias /project /home/me/projects/project/releases/current/feedback/apache/feedback.wsgi
 <Directory /home/me/projects/project/releases/current/project/apache>
   WSGIProcessGroup project-production
   Order deny,allow
   Allow from all
</Directory>
</VirtualHost>

查看错误日志,没有错误。所以我认为 000-default-backup 或 apach2.conf 中的某些内容是说“将其作为目录提供”,并且 WSGI 命令永远没有机会运行。路径都是正确的。

Apache 有服务器版本:Apache/2.2.14 (Ubuntu)。

ETA:我希望我的网站在子目录上运行,即 foo.com/project。 (我不能轻易地创建一个新的子域。)所以基本上我希望 *:80 的 VirtualHost 指令被拆分为多个文件。这可能吗?

【问题讨论】:

    标签: apache2 mod-wsgi


    【解决方案1】:

    好的,我搞定了。

    /etc/apache2/apache2.conf

    改变

    Include /etc/apache2/sites-enabled/
    

    Include /etc/apache2/sites-enabled/000-default-backup
    

    000-默认备份

    在“&lt;/VirtualHost&gt;”行之前的底部

    添加

    Include sites-enabled/*.conf
    

    我的文件

    只需删除“&lt;VirtualHost&gt;”和“&lt;/VirtualHost&gt;”行。

    【讨论】:

    • 不好的方法。将更改直接放在 000-default-backup 中会比使用单独的文件更容易。如果您确实想要多个虚拟主机,那么您所做的只会让事情变得更糟。
    • 我希望它位于一个单独的文件中,以便我可以轻松启用或禁用它,并轻松部署其他站点。你说得对,如果我有多个虚拟主机会很痛苦,但我不认为会是这样。
    【解决方案2】:

    您在任何一个 VirtualHost 中都没有 ServerName,因此 Apache 将不知道如何区分它们,只会按顺序使用第一个 VirtualHost。去检查 Apache 文档,了解正确设置 VirtualHost 所需的指令。

    【讨论】:

    • 我修改了我的问题以便更清楚。我希望我的网站在子目录 URL 上运行,而不是在它自己的(子)域上运行。在维护一个单独的文件的同时这可能吗?
    【解决方案3】:

    如果您通过 aptitude 安装,您可能还需要检查您是否有 latest version of mod_wsgi

    【讨论】:

      猜你喜欢
      • 2011-05-22
      • 2011-11-23
      • 2015-08-19
      • 1970-01-01
      • 2012-03-17
      • 1970-01-01
      • 2016-08-23
      • 2020-10-11
      相关资源
      最近更新 更多