标签:names timeout stream local not localhost end root failed
如下,如果在 server_name 中配置了一个很长的域名,那么重载 Nginx 时会报错,因此需要使用 server_names_hash_max_size 来解决域名过长的问题,该参数的作用是设置存放域名的最大散列表的存储桶的大小,根据 CPU 的一级缓存大小来设置。
server { listen 80; server_name www.abcdefghijklmnopqrst.com; # 配置一个很长的域名 location / { root html/www; index index.html index.htm; } }
[root@localhost conf]# /usr/local/nginx/sbin/nginx -t # 如果配置的域名很长会出现如下错误 nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size: 64 nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
[root@localhost ~]# cat /usr/local/nginx/conf/nginx.conf
...... http { include mime.types; server_names_hash_bucket_size 512; # 配置在 http 区块,默认是 512kb ,一般设置为 cpu 一级缓存的 4-5 倍,一级缓存大小可以用 lscpu 命令查看 default_type application/octet-stream; sendfile on; keepalive_timeout 65; server_tokens off; include vhosts/*.conf; }
标签:names timeout stream local not localhost end root failed
原文地址:http://www.cnblogs.com/pzk7788/p/6923533.html