如何使用 apache2 虚拟主机配置为两个不同的应用程序提供服务

时间:2021-04-02 18:57:00

标签: php django magento apache2 web-deployment

这里只是假设

testsite.com 这是我的 php 应用程序和

testsite.com/project 是 python 应用程序

我的 apache 站点配置文件 /etc/apache2/sites-available/site.conf

中有以下设置
<VirtualHost *:443>
                ServerAdmin webmaster@testsite.com

                DocumentRoot /var/www/html

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

<VirtualHost *:443>
                ServerAdmin webmaster@testsite.com

                DocumentRoot /var/www/html/test-project

                <Directory /var/www/html/test-project/test-project>
                    <Files wsgi.py>
                        Require all granted
                    </Files>
                </Directory>
                WSGIDaemonProcess test python-path=/var/www/html/test-project/test-project python-home=/var/www/html/test-project
                WSGIProcessGroup test
                WSGIScriptAlias / /var/www/html/test-project/test-project/wsgi.py

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

看看上面的配置,我只希望任何带有 testsite.com/ 的 url 将从第一个虚拟主机获得服务,这是我的 php 应用程序及其工作,并且只要这个特定的 testsite.com/project url 命中,它就应该得到服务来自第二个虚拟主机,这是我的 python 应用程序。

所以为了从第二个虚拟主机获得这个 url testsite.com/project,它必须从第一个虚拟主机绕过。 请建议我该怎么做?我应该在第一个虚拟主机中做什么才能绕过第二个。

注意:这与 url 重写无关,因此请不要提出任何重写规则或任何与此相关的内容。

0 个答案:

没有答案