nginx php error log 配置 查找500 错误
2016-08-16 10:44
761 查看
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的错误日志。
所以我们要进行如下的设置就能查看到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
问题解决
在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
问题解决
相关文章推荐
- 在Nginx上配置Comodo Positive SSL证书
- [Nginx] Wordpress在Nginx环境下配置伪静态
- nginx 不带www到www域名的重定向
- nginx的location配置详解
- Nginx配置文件(nginx.conf)配置详解(转载)
- 图解Linux下源码安装PHP7.0.9 +Nginx
- Centos 6让SVN提交文件自动更新到nginx的WEB目录
- nginx下配置pathinfo
- nginx 502 Bad Gateway 错误解决办法
- windows7及以上系统千万别用nginx做代理,性能不升反降
- Apache与Nginx比较 推荐
- nginx多域名配置
- 我眼中的Nginx
- Nginx的基本配置:虚拟主机、日志文件、缓存、自动列目录的配置
- 开机自动启动NGinx
- nginx配置location总结及rewrite规则写法
- nginx配置location总结及rewrite规则写法
- nginx代理后,获取request的ip
- Nginx服务器初识:Nginx启动、停止与信号控制
- centos6.5 nginx 安装部署配置负载均衡