白日依山尽,黄河入海流。欲穷千里目,更上一层楼。 -- 唐·王之涣

Nginx - Centos下Nginx报错集合

整理Centos系统下Nginx遇到的问题,一遍后续排查问题方便


[emerg] could not build the server_names_hash…

开始使用nginx只有一个虚拟主机,默认server_name 会使用 localhost, 今天配置nginx的server_name是一个正式存在的域名的时候,报错如下:

root@pts/0 $ nginx -t
nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 32
nginx: configuration file /etc/nginx/nginx.conf test failed

How to fix

在nginx的配置文件nginx.conf的http段添加如下配置:

# vi /etc/nginx/nginx.conf
...
http {
        ...
        server_names_hash_max_size 512;
        server_names_hash_bucket_size 128;
        ...
}
...

root@pts/0 $ nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

nginx官方对server_name的说明请参考 链接

公众号: DailyJobOps DailyJobOps
作者

Colin

发布于

2016-11-07

许可协议