python - 使用 apache 在子目录中运行一个 flask 网站

标签 python apache flask

我在我的个人服务器上使用 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/上运行?

最佳答案

第一个参数WSGIScriptAliasurl path , 通过指定 WSGIScriptAlias / <foo>你告诉 apache 将所有请求发送到 WSGI 应用程序。尝试 WSGIScriptAlias /something <foo>

关于python - 使用 apache 在子目录中运行一个 flask 网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14181364/

相关文章:

apache - IE 7 和 IE 8 中的 HTTPS 和 HTTP 混合内容

python - 从异步 celery worker 发出的 SocketIO 不工作

python - 将数据从文本框发送到 Flask?

python - argparse-将列表项分配给变量

python - 代码适用于 x70 列的数据框,而 1000 列的数据框则失败(相同的数据结构)

python - 大数据集的特征缩放

flask - jinja2.exceptions.TemplateSyntaxError : Encountered unknown tag 'url'

Python如何查找用户输入的字符数

apache - 是否可以 gzip 或压缩 .otf(Open Type Face)文件?

php - htaccess 创建集中的 php 文件