【问题标题】:Running a flask website in a subdirectory with apache使用 apache 在子目录中运行烧瓶网站
【发布时间】:2012-12-20 07:42:44
【问题描述】:

我在我的个人服务器上使用 apache,我正在尝试在 www.mydomain.com/ 上运行一个使用 Silex 制作的“主”网站,以及在 www.mydomain.com/something 上使用 Flask 制作的另一个网站

要运行Flask 网站,我正在使用 mod_wsgi,如他们的官方网站 (http://flask.pocoo.org/docs/deploying/mod_wsgi/) 中所述。

它工作得很好,我可以通过www.mydomain.com/something 访问我的网站,但是当我返回www.mydomain.com/ 时,我收到了Flask 404 错误消息。

我已尝试检查有关虚拟主机的 apache 文档,但我无法理解,这是我当前的 'sites-enabled/defaults' 配置文件:

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        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>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        WSGIDaemonProcess bc user=bc group=bc threads=5
        WSGIScriptAlias / /var/www/bc/bc.wsgi
        <Directory /var/www/bc>
                   WSGIProcessGroup bc
                   WSGIApplicationGroup %{GLOBAL}
                   Order deny,allow
                   Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

我的/var/www 目录如下所示:

./index.php

./bc/

./bc/index.py

我怎样才能让 python 网站只在 www.mydomain.com/something 中工作,并让 PHP 网站在 www.mydomain.com/ 上运行?

【问题讨论】:

标签: python apache flask


【解决方案1】:

WSGIScriptAlias 的第一个参数是url path,通过指定WSGIScriptAlias / &lt;foo&gt;,您告诉 apache 将所有请求发送到 WSGI 应用程序。试试WSGIScriptAlias /something &lt;foo&gt;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多