lightTPD學習筆記 (配置篇)(原創)

今天配置服務器很有靈感,大概是今天機品值與人品值均頗高所致,呵呵 :lol:

廢話少說,總結一下。希望對lightTPD初學者有所幫助,歡迎討論,一同進步嘛。

(哎呀,廢話還是不少捏)

一、servers.modules :lightTPD運行所要加載的模塊

默認形式:

	servers.modules = (
"mod_access",
"mod_alias",
# ....
# ....
)


啓動模塊只要去掉其中註釋符號就可(#),關閉某些就不用說了。

此外,還有比較酷的寫法,即:servers.modules +=( "mod_fascgi"),熟悉shell的看着眼熟吧。

二、server.document-root : lightTPD網站根目錄位置

server.document-root = "/var/www" 什麼?這個簡單?好吧,耐心點,後面講mod_evhost應用時,還會用到,相當靈巧。

三、各種日誌路徑設置參數:

1、server.errorlog : 服務器的錯誤日誌路徑參數。 example : server.errorlog = "/var/log/lighttpd/error.log"

2、accesslog.filename : 服務器的訪問日誌路徑參數。 example : accesslog.filename = "/var/log/lighttpd/access.log"

這個又簡單吧,知道你就會這麼說,後面還會講到更酷的用法。別急,繼續。。。

四、端口與索引
dir-listing.encoding = "utf-8"
端口設置 : server.port = 80 #默認爲80

目錄索引文件名設置 : index-file.names = ("index.php","index.html","index.htm","Index.php","default.htm")

是否開啓目錄列表功能,兩種寫法:

server.dir-listing = "disable" #(關閉) 或者 server.dir-listing = "enable" #(開啓)

dir-listing.activate = "disable" #(關閉) 或者 dir-listing.activate = "enable" #(開啓)


五、其他參數:

dir-listing.encoding        = "utf-8"  #目錄文件編碼

server.pid-file = "/var/run/lighttpd.pid" #進程名稱,也可在虛擬目錄中單獨設定。

server.username = "www-data" #服務用戶名(默認)

server.groupname = "www-data" #服務用戶組(默認)

alias.url = ("/doc/","/usr/share/doc/") #路徑別名設置


怎樣,設置都很簡單吧,上述都是最基本的設置。其他參數及模塊設置參考:[url]http://trac.lighttpd.net/trac/[/url]

下面來點比較酷的用法,也是非常常用的。那就是。。。。。。。。。。。。。虛擬主機的用法。嘎嘎

俺是用的ubuntu系統,由於是apt安裝的lightTPD,所以設置很方便。

$ sudo vim /etc/lighttpd/conf-enabled/10-fastcgi.conf  # 索性直接編輯這個文件添加虛擬主機。

就拿我的工作機爲例吧,公佈一下工作機的隱私,提升它的機品值,哈哈。

localhost的設置:

$HTTP["host"] == "localhost" {
server.document-root = "/var/www/" # 設置http://localhost的根目錄
alias.url += ("/php" => "/var/www/manual/html") # 設置http://localhost/php別名路徑,哈哈,這是我的php手冊地址。其實,其中的alias.url中的第一個參數都是正則,酷吧。
alias.url += ("/python" => "/var/www/manual/python") # 設置http://localhost/python別名路徑,這是我的python學習資料。
$HTTP["host"] =~ "^/python/" { # 這個寫法超酷,翻譯過來就是凡是開頭以/python的別名請求,執行以下設置。
dir-listing.activate = "enable" # 允許列出目錄所有文件
}
}

怎麼樣?酷吧,其他虛擬主機的設置參考以上吧。給我的感覺,lightTPD確實非常light~(靚仔啊)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章