我想用 PHP 设置 Lighty 在我的开发环境中使用 3 个不同的域名:
- example1.domain.com
- example2.domain.com
- example4.domain.com
我已经使用 Homebrew 安装了 PHP 5.4 和 Lighty,我的目标是在开发过程中使用类似 Rails 的解决方案来启动/停止 Web 服务器。本质上,我想要:
$ rails s
表现得像:
$ lighttpd -D -f lighttpd.conf
我已经让服务器运行,并指向 localhost:8000,但由于某些资产以上述域为前缀,因此某些资产无法正确加载。
所以对于我的问题,我如何正确配置具有上述域的虚拟主机的 Lighty?
这是我当前的 Lighty 配置:
server.bind = "0.0.0.0"
server.port = 8000
server.document-root = CWD + "/public"
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",
"mod_rewrite"
)
fastcgi.server = (
".php" => ((
"bin-path" => "/usr/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
}
# Vhost settings
$HTTP["host"] =~ "example[0-9]+.domain.com" {
server.document-root = CWD + "/public"
server.errorlog = CWD + "/lighttpd.error.log"
accesslog.filename = CWD + "/lighttpd.access.log"
}