首页 > 解决方案 > 在同一个 apache http 服务器上启动两个应用程序

问题描述

我正在开发两个应用程序,并将它们放在同一个 Apache 服务器上。我为每个应用程序在 conf 和 bin 上创建了一个文件: apa​​che/conf/httpd_app1.conf : application1 apache/conf/httpd_app2.conf : application2

apache/bin/apachectl_app1 apache/bin/apachectl_app2

我配置了每一个的虚拟主机,

但是当我指向第一个应用程序时,它会将我重定向到另一个应用程序,有时会反过来。我不明白我错过了什么以及我必须做什么。

标签: apacheredhat

解决方案


将此代码添加到 httpd.conf

<VirtualHost 172.20.30.40:80>
    ServerAdmin webmaster@www1.example.com
    DocumentRoot "/www/vhosts/www1"
    ServerName www1.example.com
    ErrorLog "/www/logs/www1/error_log"
    CustomLog "/www/logs/www1/access_log" combined
</VirtualHost>

<VirtualHost 172.20.30.50:80>
    ServerAdmin webmaster@www2.example.org
    DocumentRoot "/www/vhosts/www2"
    ServerName www2.example.org
    ErrorLog "/www/logs/www2/error_log"
    CustomLog "/www/logs/www2/access_log" combined
</VirtualHost>

推荐阅读