安装nginx
sudo pacman -S nginx
查询nginx配置文件位置
sudo nginx -t
运行结果如下:
[itkey@archlinux ~]$ sudo nginx -t
2021/03/28 10:29:01 [warn] 1503#1503: 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
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
解决警告
警告信息如下:
[warn] 1503#1503: 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
解决办法:
修改 /etc/nginx/nginx.conf 配置文件,增加
# 长连接超时时间,单位是秒
types_hash_max_size 4096;
这下运行就没有警告啦!
运行结果如下:
[itkey@archlinux ~]$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf
syntax is ok
nginx: configuration file /etc/nginx/nginx.conf
test is successful
没有警告就是开心。
修改配置以后重启 nginx
nginx -s reload
重启报错解决办法
服务器重启之后,执行 nginx -t 是OK的,然而在执行 nginx -s reload 的时候报错
nginx: [error] invalid PID number “” in “/run/nginx.pid”
解决方法:
需要先执行
nginx -c /etc/nginx/nginx.conf
nginx.conf文件的路径可以从nginx -t的返回中找到。
nginx -s reload
参考
https://*.com/questions/46031491/nginx-on-fedora-26-could-not-build-optimal-types-hash-error-message