# Ensure that Apache listens on port 80 Listen 80 # Listen for virtual host requests on all IP addresses NameVirtualHost *:80
< VirtualHost *:80> DocumentRoot /www/example1 ServerName www.example.com # Other directives here < /VirtualHost>
The asterisks match all addresses, so the main server serves no requests. Due to the fact that www.example.com is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName directives, it will be served by this first VirtualHost. [Reference Link](http://httpd.apache.org/docs/2.2/vhosts/examples.html)
>>vim /apache2/config/extra/httpd-vhosts.conf Include conf/extra/ab.example.com-vhosts.conf Include conf/extra/none.servername.com-vhosts.conf ##未配置ServrName Include conf/extra/aa.example.com-vhosts.conf Include conf/extra/bb.example.com-vhosts.conf
>>/apache2/bin/apachectl -S VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers: *:80 is a NameVirtualHost default server aa.example.com (/apache2/conf/extra/aa.example.com-vhosts.conf:1) port 80 namevhost aa.example.com (/apache2/conf/extra/aa.example.com-vhosts.conf:1) port 80 namevhost ab.example.com (/apache2/conf/extra/ab.example.com-vhosts.conf:1) port 80 namevhost aa.example.com (/apache2/conf/extra/none.servername.com-vhosts.conf:1) ## 此行:none.servername.com-vhosts.conf被错误映射到了aa.example.com port 80 namevhost bb.example.com (/apache2/conf/extra/bb.example.com-vhosts.conf:1)
>>/apache2/bin/apachectl -S VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers: *:80 is a NameVirtualHost default server aa.example.com (/apache2/conf/extra/aa.example.com-vhosts.conf:1) port 80 namevhost aa.example.com (/apache2/conf/extra/aa.example.com-vhosts.conf:1) port 80 namevhost ab.example.com (/apache2/conf/extra/ab.example.com-vhosts.conf:1) port 80 namevhost bb.example.com (/apache2/conf/extra/none.servername.com-vhosts.conf:1) ## 此行:none.servername.com-vhosts.conf被错误映射到了bb.example.com port 80 namevhost bb.example.com (/apache2/conf/extra/bb.example.com-vhosts.conf:1)