nginx: [emerg] 无法建立 server_names_hash,你应该增加 server_names_hash_bucket_size [英] nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size
问题描述
我正在设置新服务器.我选择的 http-Server 是 NGINX.我想将域 audi-freunde-einbeck.de
添加为虚拟主机.我已经在那里有 2 个其他域并且它工作正常,但是当我尝试添加上述域并启动服务器时,它给我 Job failed.详见系统日志和'systemctl status'.
我认为这是因为破折号,所以我尝试了带和不带连字符的其他各种域,但没有运气.同样的错误.什么可能导致这种情况?我也试过重启,我真的很茫然.任何帮助将不胜感激.
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 文档中引用了出现此错误时该怎么办:在这种情况下,指令值应该增加到 2 的下一个幂
.所以在你的情况下它应该变成 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.
如果仍然出现同样的错误,请尝试增加到 128 甚至更多.
If you still get the same error, try increasing to 128 and further.
参考:http://nginx.org/en/docs/http/server_names.html#optimization
这篇关于nginx: [emerg] 无法建立 server_names_hash,你应该增加 server_names_hash_bucket_size的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!