有谁告诉我为什么我仍然会出现这样的错误?
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 / {
...
最佳答案
删除“ ^”.从
原文链接:https://www.f2er.com/nginx/532402.htmlserver_name ^~(?<domain_name>[^\.]*)\.(?<tld>[^\.]*)$;
至
server_name ~(?<domain_name>[^\.]*)\.(?<tld>[^\.]*)$;
或切换“ ^”和“〜”.字母“〜”必须是第一个.
server_name ~^(?<domain_name>[^\.]*)\.(?<tld>[^\.]*)$;