nginx与apache不一样,在apache中可以直接指定php的错误日志,那样在php执行中的错误信息就直接输入到php的错误日志中,可以方便查询。
在nginx中,nginx只对页面的访问做access记录日志。不会有php的error log 信息。nginx把对php的请求发给php-fpm fastcgi进程来处理,默认的php-fpm只会输出php-fpm的错误信息,在php-fpm的errors log里也看不到php的errorlog。
原因是php-fpm的配置文件php-fpm.conf中默认是关闭worker进程的错误输出,直接把他们重定向到/dev/null,所以我们在nginx的error log 和php-fpm的errorlog都看不到php的错误日志。
[16-Aug-2016 09:59:06] WARNING: [pool www] child 12539 said into stderr: "NOTICE: PHP message: PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /alidata/www/jx_financial/system/library/log.php on line 10"
[16-Aug-2016 09:59:06] WARNING: [pool www] child 12539 said into stderr: "NOTICE: PHP message: PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /alidata/www/jx_financial/system/library/log.php on line 10"
[16-Aug-2016 09:59:06] WARNING: [pool www] child 12539 said into stderr: "NOTICE: PHP message: PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /alidata/www/jx_financial/system/library/log.php on line 10"
[16-Aug-2016 09:59:06] WARNING: [pool www] child 12539 said into stderr: "NOTICE: PHP message: PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /alidata/www/jx_financial/system/library/log.php on line 10"
[16-Aug-2016 09:59:06] WARNING: [pool www] child 12539 said into stderr: "NOTICE: PHP message: PHP Fatal error: Call to a member function get() on a non-object in /alidata/www/jx_financial/index.php on line 114"
在nginx中,nginx只对页面的访问做access记录日志。不会有php的error log 信息。nginx把对php的请求发给php-fpm fastcgi进程来处理,默认的php-fpm只会输出php-fpm的错误信息,在php-fpm的errors log里也看不到php的errorlog。
原因是php-fpm的配置文件php-fpm.conf中默认是关闭worker进程的错误输出,直接把他们重定向到/dev/null,所以我们在nginx的error log 和php-fpm的errorlog都看不到php的错误日志。
所以我们要进行如下的设置就能查看到nginx下php-fpm不记录php错误日志的方法:
1,修改
php-fpm.conf
error_log = /alidata/log/php/php-fpm.log
catch_workers_output = yes
2,修改
php.ini
log_errors = On
3,重启php-fpm
service php-fpm restart
=============================================华丽的分割线=============================================
出错信息
当调用webji的php webservicd 接口时候报错
1,只是在页面上看到500的错误,
2,在nginx的 access log 中能看到 500 返回码
58.247.1.218 - - [15/Aug/2016:16:05:35 +0800] "GET /?route=user/user/pay_problem HTTP/1.1" 500 112 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/600.1.3 (KHTML, like Gecko) Version/8.0 Mobile/12A4345d Safari/600.1.4"
3,而在nginx的error log中 无任何输出
所以必须先把error log呈现出来,通过上面配置
监听
/alidata/log/php/php-fpm.log,得到如下log
[16-Aug-2016 09:59:06] WARNING: [pool www] child 12539 said into stderr: "NOTICE: PHP message: PHP Warning: fopen(/alidata/www/jx_financial/system/logs/error.log): failed to open stream: Permission denied in /alidata/www/jx_financial/system/library/log.php on line 6"
[16-Aug-2016 09:59:06] WARNING: [pool www] child 12539 said into stderr: "NOTICE: PHP message: PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /alidata/www/jx_financial/system/library/log.php on line 10"
[16-Aug-2016 09:59:06] WARNING: [pool www] child 12539 said into stderr: "NOTICE: PHP message: PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /alidata/www/jx_financial/system/library/log.php on line 10"
[16-Aug-2016 09:59:06] WARNING: [pool www] child 12539 said into stderr: "NOTICE: PHP message: PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /alidata/www/jx_financial/system/library/log.php on line 10"
[16-Aug-2016 09:59:06] WARNING: [pool www] child 12539 said into stderr: "NOTICE: PHP message: PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /alidata/www/jx_financial/system/library/log.php on line 10"
[16-Aug-2016 09:59:06] WARNING: [pool www] child 12539 said into stderr: "NOTICE: PHP message: PHP Fatal error: Call to a member function get() on a non-object in /alidata/www/jx_financial/index.php on line 114"
至此,知道是文件权限问题,
chown www:www system -R
问题解决