天天看點

web服務之httpd虛拟主機配置你造嗎?

一、httpd虛拟主機的分類

1、基于ip位址的虛拟主機

2、基于端口的虛拟主機

3、基于域名的虛拟主機   

二、配置虛拟主機

實驗環境:centos6,使用Yum安裝的httpd服務

準備工作:注釋中心主機的DocumentRoot站點根目錄,建立/etc/httpd/conf.d/vhosts.conf配置檔案,建立實驗需的站點目錄: mkdir -pv /www/{a.com,b.net,c.org}/htdocs,每次修改配合檔案時檢查文法:httpd -t   重新開機服務:service httpd restart 

注意:在配置基于域名的虛拟主機時需加上:NameVirtualHost IP_address:Port

1、基于ip位址的虛拟主機,編輯vhosts.conf配置檔案,下圖所示:

<a href="http://s5.51cto.com/wyfs02/M01/87/FB/wKioL1fmhAuBwFXZAABIgJkecbo011.png" target="_blank"></a>

實驗測試圖:

<a href="http://s2.51cto.com/wyfs02/M01/87/FE/wKiom1fmhNfBpI7SAAB_FVI1KcA162.png" target="_blank"></a>

<a href="http://s2.51cto.com/wyfs02/M01/87/FE/wKiom1fmhRKjW6lSAABHBquT2tA297.png" target="_blank"></a>

<a href="http://s5.51cto.com/wyfs02/M02/87/FB/wKioL1fmhYew3X0LAABNWsvde88802.png" target="_blank"></a>

web服務小擴充:配置status頁面

1)開啟LoadModule status子產品  

LoadModule status_module modules/mod_status.so 

2)開啟server-status并允許所有主機或某太主機視情況而定

&lt;Location /server-status&gt;

SetHandler server-status 

Order allow,deny 

Allow from all 

&lt;/Location&gt;

3)文法測試及其重新開機配置檔案 

httpd -t 

service httpd restart 

圖示:

<a href="http://s1.51cto.com/wyfs02/M02/87/FB/wKioL1fmiDXh1r5nAABuxq0gkA8317.png" target="_blank"></a>

本文轉自chengong1013 51CTO部落格,原文連結:http://blog.51cto.com/purify/1856265,如需轉載請自行聯系原作者

繼續閱讀