天天看點

配置虛拟主機

實驗3配置基于域名(IP,端口同樣)的虛拟主機

     實驗環境

在虛拟機Linux 6.5系統下需要2台Linux系統一台A作為服務端一條B作為測試用戶端win7真實主機開啟2台Linux系統。

     實驗目标

         錯誤超連結引用無效。

網頁顯示GOOGLE

網頁顯示BAIDU

     實驗步驟

1.  首先将A,B真實主機放到同一網段中為了以後實驗友善配置永久起效的靜态IP位址驗證AB真實主機能否通信。

2.  準備顯示網頁文檔

[root@s5html]#mkdir baidu google

[root@s5html]#echo "BAIDU">baidu/index.html//首頁

[root@s5html]#echo "GOOGLE">google/index.html//首頁

3.  修改httpd服務配置.

[root@s5tools]#cd /etc/httpd/conf.d/

 [root@s5 conf.d]#vim vhosts.conf //新建立一個配置檔案

 1 NameVirtualHost 192.168.1.1

 2 <VirtualHost 192.168.1.1>

 3       ServerName www.baidu.com

 4       DocumenRoot"/var/www/html/baidu"

 5 </VirtualHost>

 6 <VirtualHost 192.168.1.1>

 7       ServerName www.google.com

 8       DocumenRoot"var/www/html/google"

      9</VirtualHost>

4.  從客戶機的浏覽器通路測試一般用真實主機測試友善

在C:\Windows\System32\drivers\etc\hosts添加域名192.168.1.1       www.baidu.com

192.168.1.1       www.google.com