Lighttpd輕量級web服務器安裝手冊
php
做者: 沈小然 html
版本: linux
文檔編號: web
日期:2008年3月17日 正則表達式
目 錄1 下載軟件包 服務器
2 安裝 ui
2.1 安裝pcre包 url
2.2.1 拷貝lighttpd配置文件和啓動腳本 .net
http://www.lighttpd.net/download
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
說明:lighttpd安裝前必需要安裝pcre包,pcre是一個包含了perl正則表達式的庫。
(如下源碼包的實際包名以具體下載版本名爲準)
# tar zxf pcre-7.6.tar.gz
# cd pcre-7.6
# ./configure
# make;make install
# tar zxf lighttpd-1.4.19.tar.gz
# cd lighttpd-1.4.19
# ./configure
執行成功後會打印出開啓的和關閉的plug插件和feature信息
# make;make install
你的lighttpd已經成功安裝到了/opt/lighttpd目錄下了。
1)拷貝配置文件到安裝目錄下。
# mkdir -p /etc/lighttpd
# cp doc/lighttpd.conf /etc/lighttpd/
2)拷貝啓動腳本到linux啓動目錄下。
# cp doc/sysconfig.lighttpd /etc/sysconfig/
# cp doc/rc.lighttpd.redhat /etc/init.d/lighttpd
由於安裝路徑與拷貝的啓動腳本中相應路徑不一樣,必須修改啓動腳本,以下:
# vi /etc/init.d/lighttpd
lighttpd="/usr/sbin/lighttpd"
改成
lighttpd="/usr/local/sbin/lighttpd"
此腳本用來控制lighttpd的啓動關閉和重起:
/etc/init.d/lighttpd start
/etc/init.d/lighttpd stop
/etc/init.d/lighttpd restart
# ps -ef|grep lighttpd 查看進程
nobody 27527 1 0 17:23 ? 00:00:00 /usr/local/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
3)建立錯誤日誌目錄,並賦予nobody:nobody屬主。不然下面的服務啓動不了。
# mkdir -p /var/log/lighttpd
# chown -R nobody.nobody /var/log/lighttpd/
官方配置各個選項參考:http://trac.lighttpd.net/trac/wiki/Docs%3AConfigurationOptions#LighttpdCoreOptions
# lighttpd -f /etc/lighttpd/lighttpd.conf –p 直接打印配置文件的配置,不含註釋信息。
# lighttpd -f /etc/lighttpd/lighttpd.conf –t 檢查配置文件的語法
Syntax OK
# vi /etc/lighttpd/lighttpd.conf
# default document-root 配置頁面主目錄
server.document-root = "/var/www/html/"
# TCP port
server.port = 80
# selecting modules 這兩個模塊必須打開。
server.modules = ( "mod_access", "mod_rewrite" )
## where to send error-messages to 錯誤日誌路徑
server.errorlog = "/var/log/lighttpd/error.log"
#### accesslog module 訪問日誌路徑
accesslog.filename = "/var/log/lighttpd/access.log"
## to help the rc.scripts pid的生成位置
server.pid-file = "/var/run/lighttpd.pid"
## change uid to <uid> (default: don't care) 默認執行用戶名
server.username = "nobody"
## change uid to <uid> (default: don't care) 默認執行組名
server.groupname = "nobody"
n 首先必須啓動 "mod_rewrite","mod_redirect","mod_alias",
n 而後在static-file.exclude-extensions中指定cgi文件的擴展名
n 最後經過cgi.assign配置指令進行關聯。
##
# which extensions should not be handle via static-file transfer
# 容許執行的擴展名
# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".cgi")
#### CGI module
$HTTP["url"] =~ "/cgi-bin/" { cgi.assign = ( "" => "", ".cgi" => "" ) }
alias.url = ( "/cgi-bin/" => "/var/www/cgi-bin/" )
說明:
須要特定解析程序執行的CGI,能夠指定解析程序的路徑,好比:
cgi.assign = ( ".pl" => "/usr/bin/perl",
".cgi" => "/usr/bin/perl" )
對於帶擴展名或不帶擴展名都不須要特定解析程序就能執行的CGI,可指定解析程序爲空,好比:
cgi.assign = ( "" => "", ".cgi" => "" )
保存