-
上海纽斯达科技
Nginx
常见错误与解决方法
上海纽斯达科技有限公司
2014-10-25
文档状态
文件状态:
【
】草稿
【
】修改稿
文档编号
作
者
审
核
人
Nsdkj-778
刘恒亮
保
密
等
级
最后完成日期
最后审核日期
最后批准日期
限制
2014-12-25
2014-12-25
2014-12-25
【
√
】正式发布
批
准
人
目的:
在
N
ginx
服务器出现故障时,能快速定位并解决相关错误。
保密:
本文档仅供内部使用,请勿外传
概述:
Nginx
< br>常见错误与问题之解决方法技术指南。
安装环境:
系统环境:
redhat enterprise 6.5
64bit
1
、
Nginx
常见启动错误
< br>有的时候初次安装
nginx
的时候会报这样的错误
p>
sbin/nginx -c
conf/
报错内容:
sbin/nginx: error while
loading shared libraries: .1:
cannot open shared object file: No such
file or directory
启动时如果报异常
error while loading
shared libraries: .1: cannot open
shared object file: No such file or
directory
这说明我们的环境还不是和启动需要
小小的配置一下
解决方法
(
直接运行
)
:
32
位系统
[root@sever
lib]# ln -s /usr/local/lib/.1 /lib
64
位系统
[root@sever
lib]# ln -s /usr/local/lib/.1 /lib64
然后执行
ps -ef | grep nginx
查看
nginx
进程确认是否真的已经启动了,
在进程列表里会
有最起码两个,
worker(nginx
< br>工作进程
)
和
master
p>
(
nginx
主进程)
root 4349 1 0 02:24 ?
00:00:00 nginx: master process sbin/nginx -c
conf/
nginx 4350
4349 0 02:24 ? 00:00:00 nginx: worker process
root 4356 28335 0 02:30 pts/1 00:00:00
grep nginx
NGINX
就
OK
了
2
、
400
bad request
错误的原因和解决办法
配置
相关设
置如下
.
client_header_buffer_size 16k;
large_client_header_buffers 4 64k;
根据具体情况调整,一般适当调整值就可以。
3
、
Nginx 502 Bad
Gateway
错误
在
和
中分别有这样两个配置项:
max_execution_time
< br>和
request_terminate_timeout
。
这两项都是用来配置一个
PHP
脚本的最大执行时间的。当超过这个时间时,
PHP-
FPM
不只会终止
脚本的执行,
p>
还会终止执行脚本的
Worker
进程。所
以
Nginx
会发现与自己通信的连接断掉了,就会返回给客<
/p>
户端
502
错误。
以
PHP-FPM
的
request_terminate_timeout=30
秒时为例,报
502 Bad
Gateway
错误的具体信息
如下:
1
)
Nginx
错误访问日志:
2013/09/19
01:09:00 [error] 27600#0: *78887 recv() failed
(104: Connection reset
by peer) while
reading response header from upstream,
client: 192.168.1.101, server: ,
request:
HTTP/1.1
host:
2
)
PHP-
FPM
报错日志:
WARNING: child
25708
exited
on
signal
15
(SIGTERM)
after
21008.883410
seconds
from
start
所以只需将这两项的值调大一些就可以让
PHP
脚
本不会因为执行时间长而被终止了。
request_terminate_timeo
ut
可以覆盖
max_execution_time
,
所以如果不想改全局的
,那只改
PHP-
FPM
的配置就可以了。
此外要注意的是
Nginx
的
< br>upstream
模块中的
max_fail
和
fail_timeout
两项。有时
Nginx
与上
游服务器(如
< br>Tomcat
、
FastCGI
)的通信只是偶然断掉了,
但
max
_fail
如果设置的比较小的话,那么在接下来的
fail_
timeout
时间内,
Nginx
都
会认为上
游服务器挂掉了,都会返回
502
错误。
所以可以将
max_fa
il
调大一些,将
fail_timeout
< br>调小一些。
4
、
Nginx
出现的
413
Request Entity Too Large
错误
这个错误一般在上传文件的时候会出现,
编辑
Nginx
主配置文件
,找到
http{}<
/p>
段,添加
client_max_body_size 10m;
//
设置多大根据自己的需求作调整
.
如果运行
php
的话这个大小
client_max_body_size
要和
中的如下值的最大值一致或
者稍大,这样就不会因为提交数据大小不一致出现的错误。
post_max_size = 10M
-
-
-
-
-
-
-
-
-
上一篇:【强烈推荐】四年级下册数学小数的意义与性质练习题
下一篇:小数的意义和读写法练习题