nginx errors

此为nginx调试中出现的问题及处理方法,主要以mark为主。

基本调试方法

日志

nginx在conf之中,可以配置日志路径及日志格式,在若出现日志,最好把access log和error log打开,以定位问题。

错误类型1

错误提示:

1
2016/03/16 18:41:42 [error] 15849#0: *32 open() "/home/work/XXXX/XXX/public/XX" failed (2: No such file or directory), client: 1.202.225.154, server: 115.28.75.150, request: "GET /betme HTTP/1.1", host: "115.28.75.150"

该错误为conf文件中路径配置的问题,可参照nginx配置检查配置。

错误提示2

错误提示

1
2016/03/16 18:43:31 [error] 15849#0: *34 connect() failed (111: Connection refused) while connecting to upstream, client: 107.151.226.203, server: 115.28.75.150, request: "GET http://www.proxy-listen.de/azenv.php HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "www.proxy-listen.de"

此错误可能是php-fpm没有安装的问题,参照博文,设置php-fpm即可。
安装nginx和php时多数已经安装,只是没有启动。因此,此处启动php-fpm。

1
2
3
4
5
6
#切换目录
cd /usr/local/php/etc
#cpdefault文件为conf文件
cp php-fpm.conf.default php-fpm.conf
#启动php-fpm
/usr/local/php/sbin/php-fpm

错误提示3

错误提示

1
2016/03/16 20:18:08 [error] 15891#0: *34 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 1.202.225.154, server: 115.28.75.150, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "115.28.75.150"