我想在我的开发环境中设置with和PHP来使用3个不同的域名:
我已经使用Homebrew安装了PHP5.4和Lighty,我的目标是有一个类似Rails的解决方案,用于在开发过程中启动/停止web服务器。基本上,我想:
$ rails s表现得像:
$ lighttpd -D -f lighttpd.conf我已经运行了服务器,并指向localhost:8000,但由于某些资产的前缀为上述指定的域,有些资产无法正确加载。
因此,对于我的问题,我如何正确配置with与虚拟主机与上述声明的域名?
下面是我当前的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"
}发布于 2013-04-26 09:34:05
我有两个想法,您可以在主配置中使用类似mod_simple_vhost或设置根目录的内容。
所以,就像:
$HTTP["host"] =~ "^example([0-9])\.domain\.com$" {
server.document-root = CWD + "/example%1/"
}或者使用mod_simple_vhost,下面是一个示例配置:
server.modules += ( "mod_simple_vhost" )
simple-vhost.server-root = CWD + "/"
simple-vhost.document-root = $HTTP["host"] + "/"
simple-vhost.default-host = "domain.com"这将为,比方说,example1.domain.com at /CWD/example1.domain.com/提供页面。如果这不起作用,请尝试simple-vhost.document-root = CWD + "/" + $HTTP["host"] + "/"。
虽然,如果您有DNS问题,要么编辑主机文件并添加域,要么配置您的名称服务器。
发布于 2013-04-24 18:38:35
如果虚拟主机都使用与主服务器配置相同的设置,则不需要配置任何虚拟主机。您应该能够将这些域添加到您的主机文件中,以便它们被定向回您的计算机,而不是输出到真正的domain.com。在mac和linux或C:\ windows \System32 32\drivers\etc\hosts上的mac和linux上的主机中添加:
127.0.0.1 example1.domain.com
127.0.0.1 example2.domain.com
127.0.0.1 example3.domain.comhttps://stackoverflow.com/questions/16024964
复制相似问题