您可以使用nginx或lighttpd
这是一个最小的 lighttpd 配置。
- 安装支持 FastCGI 的 PHP 并为您的系统调整下面的“bin-path”选项。您可以使用MacPorts安装它
sudo port install php5 +fastcgi
- 将此文件命名为 lighttpd.conf
- 然后只需
lighttpd -f lighttpd.conf
从您想要服务的任何目录运行。
- 打开你的浏览器到 localhost:8000
lighttpd.conf:
server.bind = "0.0.0.0"
server.port = 8000
server.document-root = CWD
server.errorlog = CWD + "/lighttpd.error.log"
accesslog.filename = CWD + "/lighttpd.access.log"
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
server.modules = ("mod_fastcgi", "mod_accesslog")
fastcgi.server = ( ".php" => ((
"bin-path" => "/opt/local/bin/php-cgi",
"socket" => CWD + "/php5.socket",
)))
mimetype.assign = (
".css" => "text/css",
".gif" => "image/gif",
".htm" => "text/html",
".html" => "text/html",
".jpeg" => "image/jpeg",
".jpg" => "image/jpeg",
".js" => "text/javascript",
".png" => "image/png",
".swf" => "application/x-shockwave-flash",
".txt" => "text/plain"
)
# Making sure file uploads above 64k always work when using IE or Safari
# For more information, see http://trac.lighttpd.net/trac/ticket/360
$HTTP["useragent"] =~ "^(.*MSIE.*)|(.*AppleWebKit.*)$" {
server.max-keep-alive-requests = 0
}
如果您想使用自定义 php.ini 文件,请将 bin-path 更改为:
"bin-path" => "/opt/local/bin/php-fcgi -c" + CWD + "/php.ini",
如果你想配置 nginx 来做同样的事情,这里有一个指针。