本文介绍了nginx:[emerg]无法构建server_names_hash,应增加server_names_hash_bucket_size的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置新服务器.我选择的http服务器是NGINX.我想将域audi-freunde-einbeck.de添加为虚拟主机.我已经有2个其他域了,并且工作正常,但是当我尝试添加上述域并启动服务器时,它会给我Job failed. See system journal and 'systemctl status' for details.我以为是因为破折号,所以我尝试了其他各种带或不带连字符的域名,但没有运气.同样的错误.是什么原因造成的?我也尝试过重新启动,在这里我真的很茫然.任何帮助将不胜感激.

I'm in the process of setting up a new server. The http-Server of my choice is NGINX. I want to add the domain audi-freunde-einbeck.de as a virtual host. I already have 2 other domains in there and it works fine, but when I try to add the above mentioned domain and start the server it gives me Job failed. See system journal and 'systemctl status' for details. I thought it was because of the dashes, so I tried just various other domains with and without hyphens, but no luck. Same error. what could be causing this? I also tried rebooting, I am really at a loss here. Any help would be greatly appreciated.

我玩了一段时间,发现,当我只放入一个域时,它就起作用了.但是当我放入另一个域时,它停止了.这是状态输出:

I have played around a bit and found out, that, when I only put one domain in, it works. But when I put another domain in, it stops. Here is the output in status:

[root@netzmelone nginx]# systemctl status nginx
nginx.service - A high performance web server and a reverse proxy server
      Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)
      Active: failed (Result: exit-code) since Sun, 16 Dec 2012 11:38:08 +0000; 7s ago
     Process: 14239 ExecStop=/usr/sbin/nginx -g pid /run/nginx.pid; -s quit (code=exited, status=1/FAILURE)
     Process: 14232 ExecStart=/usr/sbin/nginx -g pid /run/nginx.pid; daemon on; master_process on; (code=exited, status=0/SUCCESS)
     Process: 14242 ExecStartPre=/usr/sbin/nginx -t -q -g pid /run/nginx.pid; daemon on; master_process on; (code=exited, status=1/FAILURE)
    Main PID: 14234 (code=exited, status=0/SUCCESS)
      CGroup: name=systemd:/system/nginx.service

Dec 16 11:38:08 netzmelone nginx[14242]: nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
Dec 16 11:38:08 netzmelone nginx[14242]: nginx: configuration file /etc/nginx/nginx.conf test failed

推荐答案

由于域名太长,很可能会发生这种情况.您可以通过添加

This is most likely happening because of the long domain name. You can fix this by adding

server_names_hash_bucket_size  64;

位于http块顶部(可能位于/etc/nginx/nginx.conf中).我从nginx文档中引用了出现此错误时的处理方法:In this case, the directive value should be increased to the next power of two.因此,根据您的情况,它应该变成64.

at the top of your http block (probably located in /etc/nginx/nginx.conf). I quote from the nginx documentation what to do when this error appears: In this case, the directive value should be increased to the next power of two. So in your case it should become 64.

参考: http://nginx.org/en/docs/http/server_names.html#optimization

这篇关于nginx:[emerg]无法构建server_names_hash,应增加server_names_hash_bucket_size的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 03:18