配置apache虛擬主機

2022-03-21 19:17:41 字數 1366 閱讀 7835

說明:

在apache中,配置乙個virtualhost標籤就是乙個虛擬主機,而在nginx中,乙個server標籤就是乙個虛擬主機

配置apache虛擬主機步驟

1.檢視conf/extra/httpd-vhost.conf 配置虛擬主機的模板

--------------這裡用於配置基於ip位址或者基於埠的虛擬主機(配置多個埠或配置多個ip位址分別對應配置基於埠/ip位址的虛擬主機)

serveradmin [email protected] ---------配置管理員郵箱

documentroot "/usr/local/apache/docs/dummy-host.example.com" ---------配置站點目錄所在路徑(如/var/www/html)

servername dummy-host.example.com ---------配置虛擬主機的網域名稱(如www.test.com)

serveralias www.dummy-host.example.com ---------配置虛擬主機別名(如,test.com用於301跳轉)

errorlog "logs/dummy-host.example.com-error_log" ---------配置記錄錯誤日誌檔案存放路徑

customlog "logs/dummy-host.example.com-access_log" common ---------配置記錄**訪問日誌檔案存放路徑

2.在apache主配置檔案httpd.conf 中啟用虛擬主機功能(去掉注釋),並且新增自定義站點目錄所在路徑

--------------這裡要新增改成我們配置的存放虛擬主機目錄站點的路徑(如 /var/www/html)

options followsymlinks --------------這裡優化,沒有主頁也不顯示根目錄

allowoverride none --------------以下3項是安全方面的優化

order allow,deny

allow from all

apache虛擬主機配置

之前已經在csdn上上傳過apache的文件在這裡補充說明一下,apache2.2.x與tomcat或iis或三者之間的虛擬主機配置。介紹一下如何整合其他 web伺服器,如 iis tomcat 等。網上有 n多整合方案講的都不是很清楚 特別是 windows 下的 這裡要特別提示一下,apache...

apache虛擬主機配置

多個網域名稱 伺服器 對應乙個 ip 位址,配置方法為 namevirtualhost 111.22.33.44 servername www.sample.com documentroot www sample servername www.sample2.com documentroot www...

apache配置虛擬主機

namevirtualhost 80 directoryindex default.php index.html index.php index.htm servername www.host1.com servername host1 com documentroot d wamp www1 er...