Lighttpd - 虛擬主機(基於Header)
1. 新建vhosts.conf檔案
# vi /etc/lighttpd/conf.d/vhosts.conf
內容如下
$HTTP["host"] == "www.aaa.com" {
server.name="www.aaa.com"
server.document-root="/var/lighttpd/blog.aaa.com"
server.errorlog="/var/log/lighttpd/blog.aaa.com.error.log"
accesslog.filename="/var/log/lighttpd/blog.aaa.com.access.log"
}
$HTTP["host"] == "www.bbb.com" {
server.name="www.bbb.com"
server.document-root="/var/lighttpd/blog.bbb.com"
server.errorlog="/var/log/lighttpd/blog.bbb.com.error.log"
accesslog.filename="/var/log/lighttpd/blog.bbb.com.access.log"
}
2. 重啟lighttpd 服務
# service lighttpd restart
Stopping lighttpd: [ OK ]Starting lighttpd: [ OK ]
3. 測試
http://www.aaa.com/
# vi /etc/lighttpd/conf.d/vhosts.conf
內容如下
$HTTP["host"] == "www.aaa.com" {
server.name="www.aaa.com"
server.document-root="/var/lighttpd/blog.aaa.com"
server.errorlog="/var/log/lighttpd/blog.aaa.com.error.log"
accesslog.filename="/var/log/lighttpd/blog.aaa.com.access.log"
}
$HTTP["host"] == "www.bbb.com" {
server.name="www.bbb.com"
server.document-root="/var/lighttpd/blog.bbb.com"
server.errorlog="/var/log/lighttpd/blog.bbb.com.error.log"
accesslog.filename="/var/log/lighttpd/blog.bbb.com.access.log"
}
2. 重啟lighttpd 服務
# service lighttpd restart
Stopping lighttpd: [ OK ]Starting lighttpd: [ OK ]
3. 測試
http://www.aaa.com/