技术解析

sudo service nginx restart 错误的问题,系统是 ubuntu
0
2021-06-28 02:10:47
idczone
错误提示:Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
运行 systemctl status nginx.service 提示如下:

Nov 07 16:17:40 ip-172-31-28-177 systemd[1]: Starting A high performance web server and a reverse proxy server...
Nov 07 16:17:40 ip-172-31-28-177 nginx[10083]: nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 64
Nov 07 16:17:40 ip-172-31-28-177 nginx[10083]: nginx: configuration file /etc/nginx/nginx.conf test failed
Nov 07 16:17:40 ip-172-31-28-177 systemd[1]: nginx.service: Control process exited, code=exited status=1
Nov 07 16:17:40 ip-172-31-28-177 systemd[1]: Failed to start A high performance web server and a reverse proxy server.
Nov 07 16:17:40 ip-172-31-28-177 systemd[1]: nginx.service: Unit entered failed state.
Nov 07 16:17:40 ip-172-31-28-177 systemd[1]: nginx.service: Failed with result 'exit-code'.

网上搜了很久,说是少了一个 ";",但我检查了两次,没有少分号。请高手指教是什么问题?谢谢
大哥,你这系统不是 ubuntu 吧!

you should increase server_names_hash_bucket_size: 64
然后谷歌出的是:
http {
server_names_hash_bucket_size 64;
...
}
可以用 ngingx -t 测试配置文件。

善用 Google: https://github.com/nginxinc/kubernetes-ingress/issues/34
> set server-name-hash-bucket-size: "1024" in the configMap

贴一下 /etc/nginx/nginx.conf 文件和 sudo nginx -t 的运行结果

提示配置文件有错误,你最小化配置文件重启试试!

配置文件出错,对比老的好好看看,有没有用到全角符号之类的


nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 64
nginx: configuration file /etc/nginx/nginx.conf test failed

的方法应该可以了吧 报错里的重点就是 "you should increase server_names_hash_bucket_size" hash 桶不够,设置成 128

虚拟主机配置文件出错了,可以到 /etc/nginx/sites-enabled 目录下,把里面的软链接文件逐个删除,没删除一个,重启下 nginx ;如果哪个删后,nginx 可以重启成功了,就说明是哪个配置文件出错了,把那个仔细检查下,最后一定记得把删除后的软链接配置文件重新都加上去

数据地带为您的网站提供全球顶级IDC资源
在线咨询
专属客服