(1)www.X.com,頁面文件目錄為/web/vhosts/x;錯誤日志為/var/log/httpd/x.err,訪問日志為/var/log/httpd/x.access
(2) www.Y.com,頁面文件目錄為/web/vhosts/y;錯誤日志為 /var/log/httpd/www2.err,訪問日志為/var/log/httpd/y.access
(3)為兩個虛擬主機建立各自的主頁文件index.html,內容分別為其對應的主機名
//根據用戶訪問的主機頭不同,來返回不同的頁面
1首先建立其對應的文件目錄和各自的index.html文件:

2建立其訪問日志和錯誤日志的文件:

3建立配置文件,在/etc/httpd/conf.d建立test.conf文件:

對應的文件文件:
<VirtualHost *:80>
ServerName www.Y.com
DocumentRoot "/web/vhosts/y"
CustomLog "/var/log/httpd/y.access" combined
ErrorLog "/var/log/httpd/y.err"
<Directory "/web/vhosts/y">
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName www.X.com
DocumentRoot "/web/vhosts/x"
CustomLog "/var/log/httpd/x.access" combined
ErrorLog "/var/log/httpd/x.err"? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
<Directory "/web/vhosts/x">
Require all granted
</Directory>
</VirtualHost>
4測試語法是否正確:

5啟動服務:

6在另一臺主機配置其hosts文件,將其訪問www.Y.com和www.X.com都解析到15.140這臺機器上面:

7測試:
