官方解释
当开启 nginx.service, 进程可能会有下面的日志信息:
[warn] 18872#18872: could not build optimal types_hash, you should increase either types_hash_max_size: 1024 or types_hash_bucket_size: 64; ignoring types_hash_bucket_size
解决这个警告, 提升http代码块的下面的键的值 [4] [5]:
# /etc/nginx/nginx.conf
http {
types_hash_max_size 4096;
server_names_hash_bucket_size 128;
...
}
我是直接增大server_names_hash_bucket_size
(计算机位数的倍数增大32/64)
然后测试nginx -t
成功提示:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful