在Windows 10下,Nginx 1.10添加虚拟主机后报错:nginx: [emerg] could not build server_names_hash的解决

1、编辑nginx.conf文件,添加了整计5个虚拟主机,如图1:

编辑nginx.conf文件,添加了整计5个虚拟主机

2、执行命令:nginx -s reload,重新加载,报错,如图2:

提示信息:nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 32

翻译:nginx:[emerg]无法构建server_names_hash,应该增加server_names_hash_bucket_size:32

执行命令:nginx -s reload,重新加载,报错:nginx: [emerg] could not build server_names_hash, you should increase server_names_hash_bucket_size: 32

3、打开网址:http://nginx.org/en/docs/http/server_names.html ,查看官网相应信息,如图3:
server_names_hash_bucket_size:服务器名称长度限制,因为其中一虚拟主机的名称为:www.yii2-starter-kit.test

查看官网相应信息,server_names_hash_bucket_size:服务器名称长度限制

4、编辑nginx.conf文件,将server_names_hash_bucket_size设置为64,如图4:

编辑nginx.conf文件,将server_names_hash_bucket_size设置为64

5、执行命令:nginx -s reload,重新加载,正常,如图5:

执行命令:nginx -s reload,重新加载,正常

永夜