茫茫網海中的冷日 - 對這文章發表回應
茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1729840 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_60D_00090.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

對這文章發表回應

發表限制: 非會員 可以發表

發表者: 冷日 發表時間: 2015/9/7 7:02:05

Apache 多站點 Virtual Host 設定

咕狗了許久

結果發現Apache文件裡就有寫了
我需要的是 多個不同的網址 可以連到同一個IP的不同目錄上
Name-based Virtual Host Support
目前是Apache 2.2的

在 /etc/httpd/conf.d/ 目錄中
建立一個新的檔案 檔名隨意 副檔名必須是.conf
(我是設定vhost.conf)
將以下的碼寫進去

或是

直接在 /etc/httpd/conf/httpd.conf 檔案最後面加上以下的碼



NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>
<VirtualHost *:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain
</VirtualHost>

ServerName 當然就是網址
ServerAlias 其他網址也可以連到同一個目錄
DocumentRoot 目錄的位置

加完記得重新啟動Apache
( /etc/init.d/httpd restart )

如果啟動的過程中有[warn]說 什麼has no VirtualHost
可以在 /etc/httpd/conf/httpd.conf 裡面找找看
有沒有一行是
NameVirtualHost *:80
將這行註解起來 再重新啟動一次

參考資料:
http://httpd.apache.org/docs/current/vhosts/name-based.html
http://linux.vbird.org/linux_server/0360apache.php
http://freebsd.lab.mlc.edu.tw/apache/VirtualHost.shtml


原文出處: Apache 多站點 Virtual Host 設定 | [lifeIs: tooShort to: waste]


泠日補充:
如果設定有任何錯漏與疑惑,請愛用:

httpd -S

依照 Apache 官方的說法(a synonym for -t -D DUMP_VHOSTS)就是可以幫你檢查 httpd.conf 如何解讀你的設定囉。
內容圖示
url email imgsrc image code quote
樣本
bold italic underline linethrough   












 [詳情...]
validation picture

注意事項:
預覽不需輸入認證碼,僅真正發送文章時才會檢查驗證碼。
認證碼有效期10分鐘,若輸入資料超過10分鐘,請您備份內容後,重新整理本頁並貼回您的內容,再輸入驗證碼送出。

選項

Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|