我也为 Windows 运行 lighttpd,但我制作了我自己优化的 lighttpd mod,它支持 PHP 和 Python,我从 USB 笔式驱动器运行,因为我切换到 Windows 7,每当我访问时,所有命令行窗口都会不断出现服务器(我也不知道如何防止这种情况发生)。
我做了几件事来使我的 lighttpd 服务器更快(因为我从 USB 笔式驱动器运行它):
- 禁用各种日志(特别是访问日志)
- 保持配置文件尽可能小(我的只有 20 行)
- 仅在 .php 文件上激活 PHP,仅在 .py 文件上激活 Python
- 禁用各种你不需要的模块,比如 SSL 等等(我只有 5 个)
这是我的配置文件:
var.Doo = "C:/your/base/path/here"
# LightTPD Configuration File
server.port = 80
server.name = "localhost"
server.tag = "LightTPD/1.4.20"
server.document-root = var.Doo + "/WWW/"
server.upload-dirs = ( var.Doo + "/TMP/" )
server.errorlog = var.Doo + "/LightTPD/logs/error.log"
server.modules = ( "mod_access", "mod_cgi", "mod_dirlisting", "mod_indexfile", "mod_staticfile" )
# mod_access
url.access-deny = ( ".db" )
# mod_cgi
cgi.assign = ( ".php" => var.Doo + "/PHP/php-cgi.exe", ".py" => var.Doo + "/Python/python.exe" )
# mod_dirlisting
dir-listing.activate = "enable"
# mod_indexfile
index-file.names = ( "index.php", "index.html" )
# mod_mimetype
mimetype.assign = ( ".css" => "text/css", ".gif" => "image/gif", ".html" => "text/html", ".jpg" => "image/jpeg", ".js" => "text/javascript", ".png" => "image/png", ".txt" => "text/plain", ".xml" => "text/xml" )
# mod_staticfile
static-file.exclude-extensions = ( ".php", ".py" )
以及我活跃的模块:
- mod_access
- mod_cgi
- mod_dirlisting
- mod_indexfile
- mod_staticfile
底线是,即使从 USB 笔运行,服务器仍然非常快。
PS:我也考虑过切换到 nginx,但考虑到我可以获得的当前性能以及 nginx 的更小的用户群,我决定保留 LightTPD。