我的站点中的configuration文件中有以下两个服务器块可用:
server { listen 80; server_name www.mydomain.be; root /usr/share/nginx/html; index index.html index.htm; location / { try_files $uri $uri/ =404; } } server { listen 80; server_name sub.mydomain.be; root /usr/share/nginx/sub; index index.html index.htm; location / { try_files $uri $uri/ =404; } }
我还为我的服务器的IP地址创build了www.domain.be和sub.domain.be的Alogging。
然而,当我尝试重新加载我的nginxconfiguration与服务nginx重新加载失败。
当我删除第二个服务器块,它按预期重新加载。
我知道这个主题很受欢迎,这里有很多这样的[nginx] [子域]问题,但是他们都没有明确地讨论以下三件事情是如何结合在一起的:
现在我有一个印象,就是对这个更大的图片缺乏了解,而不是对nginxconfiguration的具体了解使得我无法做这个工作。
更新:
追查问题
最初我失败了,没有任何解释。
运用
sudo nginx -c /etc/nginx/nginx.conf -t
我收到了这个消息
nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
取消注释后
server_names_hash_bucket_size 64;
问题解决了。
跟踪问题(与A-records或/ etc / hosts文件无关)
最初我失败了,没有任何解释。
运用
sudo nginx -c /etc/nginx/nginx.conf -t
我收到了这个消息
nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
取消注释后
server_names_hash_bucket_size 64;
在nginx.conf中解决了这个问题。