nginx之常见错误
原创
©著作权归作者所有:来自51CTO博客作者zlixing的原创作品,请联系作者获取转载授权,否则将追究法律责任
在此只介绍源码安装nginx的时候,发生的一些常见的错误
1. nginx访问出现File not found
1) php-fpm找不到SCRIPT_FILENAME中执行的PHP文件
更改配置文件nginx.conf
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
替换成下面
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
然后重新加载nginx配置文件
/etc/init.d/nginx reload
2) php-fpm不能访问执行的PHP,权限问题
两种解决方法:
第一种,就是把你root文件夹设为其他用户允许
第二种,找到你的php-fpm的配置文件,找到下面这段,把apache替换成你要的用户组
; RPM: apache Choosed to be able to access some dir as httpd
user = apache
; RPM: Keep a group allowed to write in log dir.
group = apache
2. [emerg]: getpwnam(“nginx”) failed
没有安装nginx用户导致无法启动
useradd -s /sbin/nologin -M nginx
id nginx
3.
client intended to send too large body文件上传报错
原因:nginx中设置了最大文件大小,如果没有设置则默认1M大小的限制
解决:客户端最大上传文件的大小
# 配置nginx上传文件最大限制
client_max_body_size 50m;
可以在http 中或者server中进行设置
或者location / {
client_max_body_size:10m;
}
4.
Nginx a client request body is buffered to a temporary file
查看nginx的错误日志发现
a client request body is buffered to a temporary file /opt/app/nginx/client_body_temp/0001539931
从字面意思猜测应该是某个设置项比较小,导致写入到磁盘临时空间。经搜索资料后修改
client_max_body_size 10m;
client_body_buffer_size 1024k; // 这个参数
5.
/usr/local/nginx/sbin/nginx: error while loading shared libraries: .2: cannot open