首先在http.conf文件中增加监听端口

Listen 8081
Listen 8090

配置apache访问的根目录

ServerName 10.x.x.138:8090

DocumentRoot "/act_data/apache2/htdocs"

配置目录路径

<Directory "/act_data/apache2/htdocs">

    Options Indexes FollowSymLinks

    AllowOverride None

    Order allow,deny
    Allow from all

</Directory>


 

(可选) 可以将不同的访问路径别名

<IfModule alias_module>

    Alias /index.php /act_data/apache2/htdocs/count

    ScriptAlias /cgi-bin/ "/act_data/apache2/cgi-bin/"

</IfModule>

 

允许访问php

    AddType application/x-httpd-php .php

开启虚拟配置

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

 

在extra中的httpd-vhosts.conf对虚拟机访问路径进行配置

NameVirtualHost 10.28.7.138

<VirtualHost 10.x.x.138:8090>
    ServerName localhost
    DocumentRoot "/act_data/apache2/htdocs/count/"
    <Directory "/act_data/apache2/htdocs/count/">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

<VirtualHost 10.x.x.138:8081>
    ServerName localhost
    DocumentRoot "/act_data/apache2/htdocs/countskin/"
    <Directory "/act_data/apache2/htdocs/countskin/">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>
</VirtualHost>

 

检查虚拟主机配置是否正确

apachectl -S  #a synonym for -t -D DUMP_VHOSTS


VirtualHost configuration:
...

Syntax OK

 

apachectl  -t -D [10.x.x.138:8090 | DUMP_VHOSTS | DUMP_MODULES]