首页 > 解决方案 > How to set fastcgi_params_hash_max_size?

问题描述

On my Ubuntu server running Nginx + FastCGI (via Webinoly), nginx -t throws the following warning:

    nginx: [warn] could not build optimal fastcgi_params_hash, 
you should increase either fastcgi_params_hash_max_size: 512 or 
fastcgi_params_hash_bucket_size: 64; ignoring fastcgi_params_hash_bucket_size

At first I thought that I had to change server_names_hash_max_size, but it was already set to 2048 and was unrelated. To make sure, I tried lowering its value to 8, at which nginx -t threw a warning that I should increase it. After restoring it, I got back the initial warning about fastcgi_params_hash_max_size.

I also tried setting fastcgi_params_hash_max_size on my nginx.conf file, but then I got an error that fastcgi_params_hash_max_size is an unknown directive.

So, I guess my question is, how can I change the fastcgi_params_hash_max_size?

Thanks in advance!

标签: nginxfastcgi

解决方案


确实没有fastcgi_params_hash_max_sizefastcgi_params_hash_bucket_size指令。此错误消息是“自动”的,它采用哈希名称(在本例中fastcgi_params_hash),然后通过附加_max_sizeand构造建议的指令名称_bucket_size

NGINX 哈希通常用于存储类似数组的配置数据,如maps 或fastcgi_paramss (您的情况),并且有关于它们的单独文档不得不说:

大多数散列具有允许更改这些参数的相应指令,例如,对于服务器名称散列,它们是 server_names_hash_max_size 和 server_names_hash_bucket_size。

所以你的哈希没有“相应的指令”,除了:

  • 调查为什么您的配置中有太多fastcgi_param指令?(或具有太多冗长的值)。您很可能对fastcgi_paramss 有次优配置。请记住,这些被传递给 FastCGI(例如 PHP-FPM),如果数据太大,那么您肯定会遇到性能问题,因为 NGINX-PHP-FPM 之间传递的数据过多。
  • 向 NGINX 提交关于添加这些指令的错误问题

推荐阅读