问题:
现在的配置方式
# in a server {} section at a vhost there's
# set $base_domain domain.com;
# and then it includes another config file which has something like this:
if ($php_logs_path = '') {
set $php_logs_path /a/b/$base_domain/logs/$server_name.php_www_errors.log;
}
fastcgi_parma PHP_ADMIN_VALUE "error_log=$php_logs_path"
这工作正常,日志文件出现在正确的路径:
/a/b/domain.com/logs/some-sub-domain.domain.com.php_www_errors.log
答案1:
使用一些全局map
指令呢
map $server_name $base_domain {
~([^.]*).([^.]*)$ $1.$2;
}
map
块在http
上下文中定义,因此你可以在全局vhosts config中单独定义它。
答案2:
你为什么不重用$server_name
?此变量设置为在server
块中定义的第一个server_name
。
相关文章