从php脚本显示虚拟主机


Display virtual hosts from a php script?

我希望能够构建一个脚本,将显示在我的Apache (Ubuntu)开发机器下运行的所有虚拟主机。

到目前为止,我还没有找到任何例子或任何接近我想要的东西,这只是:

"显示这台机器上运行的所有虚拟主机"。(服务器名,别名等)。

我想我可能能够读取/etc/apache2/sites-available文件夹,其中包含vhosts的所有配置文件,但在继续这条路之前,我想我应该先问一下这里

可以使用apachectl(或apache2ctl)命令通知httpd Apache服务器转储虚拟主机信息:

 apache2ctl -St

这里是使用apachectl发送信号和httpd标志的链接。

下面是我的Apache/Ubuntu系统(我是一个有一堆虚拟主机的web开发人员):

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server 127.0.1.1 (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/000-default:1)
         port 80 namevhost adaleco (/etc/apache2/sites-enabled/adaleco:1)
         port 80 namevhost amcham (/etc/apache2/sites-enabled/amcham:1)
         port 80 namevhost cake (/etc/apache2/sites-enabled/cake:1)
         port 80 namevhost cakeplate (/etc/apache2/sites-enabled/cakeplate:1)
         port 80 namevhost coord (/etc/apache2/sites-enabled/coord:1)
         port 80 namevhost dru1 (/etc/apache2/sites-enabled/dru1:1)
         port 80 namevhost flaming (/etc/apache2/sites-enabled/flaming:1)
         port 80 namevhost flaming6 (/etc/apache2/sites-enabled/flaming6:1)
         port 80 namevhost food (/etc/apache2/sites-enabled/food:1)
         port 80 namevhost fun (/etc/apache2/sites-enabled/fun:1)
         port 80 namevhost marc (/etc/apache2/sites-enabled/marc:1)
         port 80 namevhost sugar (/etc/apache2/sites-enabled/sugar:1)
         port 80 namevhost vol (/etc/apache2/sites-enabled/vol:1)
         port 80 namevhost xmas (/etc/apache2/sites-enabled/xmas:1)
Syntax OK