有没有人告诉我为什么我还有这样的错误?
Restarting nginx: [emerg]: unknown "domain_name" variable
configuration file /etc/nginx/nginx.conf test failed
代码中变量的部分如下所示:
server {
# if you're running multiple servers, instead of "default" you should
# put your main domain name here
listen 80 default;
# you could put a list of other domain names this application answers
server_name ^~(?<domain_name>[^\.]*)\.(?<tld>[^\.]*)$;
# root defined by domain
root /home/deployer/apps/$domain_name/current/;
# access && error && rewrite log
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
rewrite_log on;
# default location
location / {
...
答案 0 :(得分:4)
删除&#34; ^&#34;。从
server_name ^~(?<domain_name>[^\.]*)\.(?<tld>[^\.]*)$;
要
server_name ~(?<domain_name>[^\.]*)\.(?<tld>[^\.]*)$;
或切换&#34; ^&#34;和&#34;〜&#34;。这封信&#34;〜&#34;必须是第一个。
server_name ~^(?<domain_name>[^\.]*)\.(?<tld>[^\.]*)$;