Lighttpd php fastcgi Windows 安裝

其實安裝Lighttpd不需要什麼別的軟件,去https://www.kevinworthington.com/?s=lighttpd下載編譯好的win32版就好了(本人用的是zip包,exe版類似)。
1.解壓到任何目錄(最好是英文目錄,其他語言的沒試過),如d:\inetpub\LightTPD;我的系統環境:Vista32 中文版,PHP5.2.3和5.2.4,mysql 5.0.45;
以下的conf、bat和RunHiddenConsole.exe可以在這裏下載:http://www.box.net/shared/vfvqyjhday
2.打開conf文件夾,將lighttpd-inc.conf備份;
3.修改這個配置文件,我的配置如下(精簡過的)#後面的是註釋,詳細註釋前往官方文檔http://trac.lighttpd.net/trac/wiki/Docs及本論壇的好帖http://www.lighttpd.net.cn/showthread.php?t=11217

#定義lighttpd所在目錄
var.root = "D:/Inetpub/Lighttpd"
#啓用的modules(詳細見原版lighttpd-inc.conf)
server.modules              = (
"mod_access",
"mod_cgi",
"mod_accesslog",
"mod_alias",
#"mod_fastcgi"
)
#服務的目錄
server.document-root        = "D:/Inetpub/www/"
server.errorlog             = var.root + "/logs/lighttpd.error.log"
server.upload-dirs          = (var.root + "/tmp")
accesslog.filename          = var.root + "/logs/access.log"
#默認首頁
index-file.names            = ( "index.php", "index.html", "index.htm" )
#使用php
static-file.exclude-extensions = ( ".php" )
#使用CGI php的定義
cgi.assign                 = ( ".php"  =>  "D:/Inetpub/php/php-cgi.exe")
#使用fastcgi PHP(win版下可使用)
#fastcgi.server = ( ".php" =>( "localhost" =>("host" => "127.0.0.1","port" => 521 )))
mimetype.assign             = (
  ".pdf"          =>      "application/pdf",
  ".sig"          =>      "application/pgp-signature",
  ".spl"          =>      "application/futuresplash",
  ".class"        =>      "application/octet-stream",
  ".ps"           =>      "application/postscript",
  ".torrent"      =>      "application/x-bittorrent",
  ".dvi"          =>      "application/x-dvi",
  ".gz"           =>      "application/x-gzip",
  ".pac"          =>      "application/x-ns-proxy-autoconfig",
  ".swf"          =>      "application/x-shockwave-flash",
  ".tar.gz"       =>      "application/x-tgz",
  ".tgz"          =>      "application/x-tgz",
  ".tar"          =>      "application/x-tar",
  ".zip"          =>      "application/zip",
  ".mp3"          =>      "audio/mpeg",
  ".m3u"          =>      "audio/x-mpegurl",
  ".wma"          =>      "audio/x-ms-wma",
  ".wax"          =>      "audio/x-ms-wax",
  ".ogg"          =>      "application/ogg",
  ".wav"          =>      "audio/x-wav",
  ".gif"          =>      "image/gif",
  ".jpg"          =>      "image/jpeg",
  ".jpeg"         =>      "image/jpeg",
  ".png"          =>      "image/png",
  ".xbm"          =>      "image/x-xbitmap",
  ".xpm"          =>      "image/x-xpixmap",
  ".xwd"          =>      "image/x-xwindowdump",
  ".css"          =>      "text/css",
  ".html"         =>      "text/html",
  ".htm"          =>      "text/html",
  ".js"           =>      "text/javascript",
  ".asc"          =>      "text/plain",
  ".c"            =>      "text/plain",
  ".cpp"          =>      "text/plain",
  ".log"          =>      "text/plain",
  ".conf"         =>      "text/plain",
  ".text"         =>      "text/plain",
  ".txt"          =>      "text/plain",
  ".dtd"          =>      "text/xml",
  ".xml"          =>      "text/xml",
  ".mpeg"         =>      "video/mpeg",
  ".mpg"          =>      "video/mpeg",
  ".mov"          =>      "video/quicktime",
  ".qt"           =>      "video/quicktime",
  ".avi"          =>      "video/x-msvideo",
  ".asf"          =>      "video/x-ms-asf",
  ".asx"          =>      "video/x-ms-asf",
  ".wmv"          =>      "video/x-ms-wmv",
  ".bz2"          =>      "application/x-bzip",
  ".tbz"          =>      "application/x-bzip-compressed-tar",
  ".tar.bz2"      =>      "application/x-bzip-compressed-tar"
 )
#虛擬目錄
alias.url = ( "/ma/" => "D:/Inetpub/ma/" )
#偵聽端口
server.port                = 81
mimetype.use-xattr        = "enable"
#無首頁是否列文件目錄
dir-listing.activate        = "enable"
#服務器的版本好(好像是列目錄時顯示的)
server.tag                 = "lighttpd/1.4.18i-win32"
url.access-deny             = ( "~", ".inc" )
$HTTP["url"] =~ ".pdf$" {
  server.range-requests = "disable"
}
4.寫運行Lighttpd的批處理文件放在lighttpd的根目錄下:
運行CGI php:
start_lighttpd - cgi.bat

@ECHO OFF
ECHO Starting lighttpd...
#重點是這句,-m指定mod文件的位置(一般不需要修改),-f指定配置文件的位置
LightTPD.exe -m lib -f conflighttpd.conf
IF %errorlevel% GTR 0 (
  ECHO Starting lighttpd failed!
  PAUSE
) ELSE (
  ECHO Starting lighttpd succeed!
)
運行fastcgi php:
a.先確保在conf中使用mod_fastcgi,和配置了fastcgi.server;
b.start_lighttpd - fastcgi.bat,RunHiddenConsole.exe 在官方網站有下(也可以不使用,不過回留下一個cmd的窗口)

@ECHO OFF
ECHO Starting PHP FastCGI...
#運行php-cgi.exe
RunHiddenConsole.exe ..PHPphp-cgi.exe -b 127.0.0.1:521
ECHO Starting LightTPD...
ECHO.
lighttpd.exe -v
ECHO.
lighttpd.exe -f etclighttpd.conf -m lib
EXIT
關閉Lighttpd:
stop_lighttpd - cgi.bat

@ECHO OFF
ECHO Stoping lighttpd...
binProcess -k LightTPD.exe
ping 127.0.0.1 > NUL
stop_lighttpd_fastcgi.bat

@ECHO OFF
ECHO Stopping LightTPD...
binprocess.exe -k lighttpd.exe >nul
ECHO Stopping PHP FastCGI...
binprocess.exe -k php-cgi.exe >nul
ECHO.
EXIT
重啓Lighttpd:
restart_lighttpd.bat

@ECHO OFF
CALL stop_lighttpd.bat
CALL start_lighttpd.bat
5.也可以去bin目錄把lighttpd配置成windows的系統服務。
備註:
運行fastcgi模式的時候,可以把批處理改成這樣,沒有CMD窗口。
 這個編譯過的lighttpd的配置文件被改成lighttpd-inc.conf了。所以下面要改一下。
@ECHO OFF
ECHO Starting PHP FastCGI...
#運行php-cgi.exe
RunHiddenConsole.exe ..PHPphp-cgi.exe -b 127.0.0.1:521
ECHO Starting LightTPD...
ECHO.
lighttpd.exe -v
ECHO.
RunHiddenConsole.exe lighttpd.exe -f lighttpd-inc.conf -m lib
EXIT
本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/Matt_Hwang/archive/2007/11/03/1865156.aspx
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章