Lighttpd - 虛擬主機(基於IP)
# mkdir /var/lighttpd/blog.aaa.com
# chown -R lighttpd.lighttpd /var/lighttpd/blog.aaa.com
# mkdir /var/lighttpd/blog.bbb.com
# chown -R lighttpd.lighttpd /var/lighttpd/blog.bbb.com
2. 新建vhosts.conf檔案
# vi /etc/lighttpd/conf.d/vhosts.conf
內容如下
$HTTP["host"] == "192.168.11.201" {
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"] == "192.168.11.202" {
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"
}
3. 編輯lighttpd.conf檔案
# vi /etc/lighttpd/lighttpd.conf
內容如下
include "conf.d/vhosts.conf"
4. 重啟lighttpd 服務
# service lighttpd restart
Stopping lighttpd: [ OK ]Starting lighttpd: [ OK ]
5. 測試
# vi /var/lighttpd/blog.aaa.com/index.html
內容如下
<HTML>
<BODY>
<center><H1>blog.aaa.com</H1></center>
</BODY>
</HTML>
# vi /var/lighttpd/blog.bbb.com/index.html
<HTML>
<BODY>
<center><H1>blog.bbb.com</H1></center>
</BODY>
</HTML>