发现php 运行错误时,浏览器的网页上并没有输出php的错误日志。那php的错误日志在哪里呢? 发现在 /var/log/nginx/error.log文件中。

怎么样才能在浏览器的网页中输出php的出错信息呢?

编辑 /etc/php5/fpm/php.ini文件,将display_errors = On. (如果不改php.ini文件,只是在执行文件中 ini_set("display_errors", "on"))发现没效果,不知道为什么呢?奇怪!!

这样改了php.ini文件后,网页上就可以看到php的出错信息了,便于调试。

-------------------------------------------------------------------------------------------------

I gathered insights from a bunch of answers here and I present a comprehensive solution:

So, if you setup nginx with php5-fpm and log a message using error_log() you can see it in /var/log/nginx/error.log by default.

A problem can arise if you want to log a lot of data (say an array) using error_log(print_r($myArr, true));. If an array is large enough, it seems that nginx will truncate your log entry.

To get around this you can configure fpm to manage logs. Here are the steps to do so.

  1. Open /etc/php5/fpm/pool.d/www.conf:

    $ sudo nano /etc/php5/fpm/pool.d/www.conf

  2. Uncomment the following two lines by removing ; at the beginning of the line:

    ;php_admin_value[error_log] = /var/log/fpm-php.www.log ;php_admin_flag[log_errors] = on

  3. Create /var/log/fpm-php.www.log:

    $ sudo touch /var/log/fpm-php.www.log;

  4. Change ownership of /var/log/fpm-php.www.log so that php5-fpm can edit it:

    $ sudo chown vagrant /var/log/fpm-php.www.log

    Note: vagrant is the user that I need to give ownership to. You can see what user this should be for you by running $ ps aux | grep php.*www and looking at first column.

  5. Restart php5-fpm:

    $ sudo service php5-fpm restart

Now your logs will be in /var/log/fpm-php.www.log.

nginx+php-fpm 的配置下,php的错误日志的更多相关文章

  1. 第四百零五节,centos7下搭建sentry错误日志服务器,接收python以及Django错误,

    第四百零五节,centos7下搭建sentry错误日志服务器,接收python以及Django错误, 注意:版本,不然会报错 Docker >=1.11Compose >1.6.0 通过d ...

  2. Centos 7 上使用nginx为Node.js配置反向代理时错误:(13: Permission denied) while connecting to upstream

    错误来源:Centos 7 上使用nginx为Node.js配置反向代理时产生(13: Permission denied) while connecting to upstream的错误 nginx ...

  3. ASP.NET 配置log4net启用写错误日志功能

    http://www.cnblogs.com/yeminglong/archive/2013/05/21/3091192.html 首先我们到apche的官网下载log4net的项目编译得到log4n ...

  4. ubuntu1404下Apache2.4错误日志error.log路径位置

    首先打开/etc/apache2路径下的apache2.conf文件,找到ErrorLog如下 ErrorLog ${APACHE_LOG_DIR}/error.log 这里{APACHE_LOG_D ...

  5. linux(centos8):zabbix配置邮件报警(监控错误日志)(zabbix5.0)

    一,zabbix5.0发邮件报警的准备工作: zabbix5.0在linux平台上的安装:参见这一篇: https://www.cnblogs.com/architectforest/p/129125 ...

  6. ASP.NET/MVC 配置log4net启用写错误日志功能

    <?xml version="1.0" encoding="utf-8"?> <!-- 有关如何配置 ASP.NET 应用程序的详细信息,请访 ...

  7. centos7下搭建sentry错误日志服务器

    1. docker 安装(方法一) 1.确保yum packages 是最新的 $ sudo yum update 2.添加yum repo $ sudo tee /etc/yum.repos.d/d ...

  8. 寻找Windows下MySQL的错误日志

    https://blog.csdn.net/dreamcs/article/details/53502625

  9. Linux下查看mysql错误日志

    1.进入 mysql 安装目录 进入 data 目录(该目录存储的是数据库的数据) cd  /usr/local/mysql ll 进入 mysql 目录 ,发现 文件后缀 .err,即是mysql ...

  10. nginx使用ssl模块配置支持HTTPS访问

    默认情况下ssl模块并未被安装,如果要使用该模块则需要在编译nginx时指定–with-http_ssl_module参数. 需求: 做一个网站域名为 www.localhost.cn 要求通过htt ...

随机推荐

  1. 关于Cocos2dx之JS创建项目

    环境: cocos2dx -3.10 ndk - r9 sdk 1.进入到指定的项目的目标目录下面去,然后执行cocos new -l js ProjectName 进入对应目录查看:

  2. Nimbus<二>storm启动nimbus源码分析-nimbus.clj

    nimbus是storm集群的"控制器",是storm集群的重要组成部分.我们可以通用执行bin/storm nimbus >/dev/null 2>&1 &a ...

  3. Excel教程(8) - 财务函数

    ACCRINT 用途:返回定期付息有价证券的应计利息. 语法:ACCRINT(issue,first_interest, settlement, rate,par,frequency, basis) ...

  4. python--随机函数(random,uniform,randint,randrange,shuffle,sample)

    random() random()方法:返回随机生成的一个实数,它在[0,1)范围内 运用random()方法的语法: import random #random()方法不能直接访问,需要导入rand ...

  5. ***参考Catch That Cow(BFS)

    Catch That Cow Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Tot ...

  6. 10个男孩和n个女孩共买了n2+8n+2本书,已知他们每人买的书本的数量是相同的,且女孩人数多于南海人数,问女孩人数是多少?(整除原理1.1.3)

    10个男孩和n个女孩共买了n2+8n+2本书,已知他们每人买的书本的数量是相同的,且女孩人数多于南海人数,问女孩人数是多少? 解: 因为,每个人买的书本的数量是相同的, 所以,10|n2+8n+2 所 ...

  7. 2. Shell 传递参数

    1. 概要 我们可以在执行 Shell脚本时,向脚本传递参数,脚本内获取参数的格式为:$n.n 代表一个数字,1 为执行脚本的第一个参数,2 为执行脚本的第二个参数,以此类推-- #!/bin/bas ...

  8. Thrift源码解析--TBinaryProtocol

    本文为原创,未经许可禁止转载. 关于Tprotocol层都是一些通信协议,个人感觉内容较大,很难分类描述清楚.故打算以TBinaryProtocol为例,分析客户端发请求以及接收服务端返回数据的整个过 ...

  9. jquety选择器

    基本选择器 1.#id        根据id的属性值来获取元素 2.TagName     根据标签名来获取元素 3.selector1,selector2    匹配列表中的选择器(就是可以匹配多 ...

  10. 将当天时间转换为unix时间戳

    /** * @return * * @Title: getDate * @Description: TODO(时间戳转换为String类型的日期数据) * @param @param unixDate ...