对于服务器上面运行的PHP代码,期间的log输出到哪里。

想要去查看对应的log,找到代码无法运行的原因。

【折腾过程】

1.搜:

check php log

centos check php log

参考:

Where does PHP store the error log? – Stack Overflow

apache2 – Where are the Apache and PHP log files? – Ask Ubuntu

去看看:

自己此处的/var/log/下面没有apache2或apache

2.通过:

phpinfo()

去找error_log

结果得到:

error_log

no value

no value

3.所以去设置php.ini的log日志:

【已解决】CentOS 7中PHP配置文件php.ini的放在哪个位置

4.然后去编辑php.ini,添加对应的error_log

vi /etc/php.ini

把:

?

1

2

3

4

5

6

7

; Log errors to specified file. PHP's default behavior is to leave this value

; empty.

; http://php.net/error-log

; Example:

;error_log = php_errors.log

; Log errors to syslog (Event Log on NT, not valid in Windows 95).

;error_log = syslog

改为:

?

1

2

3

4

5

6

7

; Log errors to specified file. PHP's default behavior is to leave this value

; empty.

; http://php.net/error-log

; Example:

error_log = /var/log/php_errors.log

; Log errors to syslog (Event Log on NT, not valid in Windows 95).

;error_log = syslog

5.同时把:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

; error_reporting

;   Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED

;   Development Value: E_ALL

;   Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

......

;                     and forward compatibility of your code

; E_CORE_ERROR      - fatal errors that occur during PHP's initial startup

; E_CORE_WARNING    - warnings (non-fatal errors) that occur during PHP's

;                     initial startup

; E_COMPILE_ERROR   - fatal compile-time errors

; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)

; E_USER_ERROR      - user-generated error message

; E_USER_WARNING    - user-generated warning message

; E_USER_NOTICE     - user-generated notice message

; E_DEPRECATED      - warn about code that will not work in future versions

;                     of PHP

; E_USER_DEPRECATED - user-generated deprecation warnings

;

; Common Values:

;   E_ALL (Show all errors, warnings and notices including coding standards.)

;   E_ALL & ~E_NOTICE  (Show all errors, except for notices)

;   E_ALL & ~E_NOTICE & ~E_STRICT  (Show all errors, except for notices and coding standards warnings.)

;   E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR  (Show only errors)

; Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED

; Development Value: E_ALL

; Production Value: E_ALL & ~E_DEPRECATED & ~E_STRICT

; http://php.net/error-reporting

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

改为:

?

1

2

#error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

error_reporting = E_ALL | E_STRICT

6.再去添加读写权限:

cd  /var/log

1

2

3

4

5

6

7

8

9

root@chantyou:log# pwd

/var/log

root@chantyou:log# touch /var/log/php_errors.log

root@chantyou:log# ls /var/log/php_errors.log -l

-rw-r--r-- 1 root root 0 Jul 28 16:03 /var/log/php_errors.log

root@chantyou:log# chmod +rw /var/log/php_errors.log

root@chantyou:log# ls /var/log/php_errors.log -l    

-rw-r--r-- 1 root root 0 Jul 28 16:03 /var/log/php_errors.log

root@chantyou:log#

此处由于都是root用户,所以和没添加一样。。。

7.然后重启apache2:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

root@chantyou:log# service httpd restart

Redirecting to /bin/systemctl restart  httpd.service

root@chantyou:log# service httpd status

Redirecting to /bin/systemctl status  httpd.service

httpd.service - The Apache HTTP Server

   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled)

   Active: active (running) since Tue 2015-07-28 16:05:13 CST; 7s ago

  Process: 6858 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=0/SUCCESS)

  Process: 2224 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)

 Main PID: 6864 (httpd)

   Status: "Processing requests..."

   CGroup: /system.slice/httpd.service

           ├─6864 /usr/sbin/httpd -DFOREGROUND

           ├─6866 /usr/sbin/httpd -DFOREGROUND

           ├─6867 /usr/sbin/httpd -DFOREGROUND

           ├─6868 /usr/sbin/httpd -DFOREGROUND

           ├─6869 /usr/sbin/httpd -DFOREGROUND

           └─6870 /usr/sbin/httpd -DFOREGROUND

Jul 28 16:05:13 chantyou.com httpd[6864]: AH00548: NameVirtualHost has no effect and will be removed in the next release /e...conf:1

Jul 28 16:05:13 chantyou.com httpd[6864]: AH00558: httpd: Could not reliably determine the server's fully qualified domain ...essage

Jul 28 16:05:13 chantyou.com systemd[1]: Started The Apache HTTP Server.

Hint: Some lines were ellipsized, use -l to show in full.

root@chantyou:log#

8.看看有无log输出了:

?

1

2

root@chantyou:log# tail /var/log/php_errors.log

root@chantyou:log#

结果空的。

那就继续去测试其他php,如果出错了,希望此处可以看到错误的log日志。

9.然后,也确定了phpinfo()中是可以看到有错误日志的配置了:

error_log

/var/log/php_errors.log

/var/log/php_errors.log

【总结】

暂时反正是设置了PHP的错误日志,但是实际上后续的一些错误,比如代码的语法错误,结果却没有任何输出。

感觉可能还是某些地方禁止了错误输出。

估计是那个:

display_errors

CentOS 7中查看PHP运行时的Log文件日志信息相关推荐

  1. 5G信令(就是用户身份信息)——手机开机后,先从USIM中读取之前运营商分配的临时身份信息GUTI/TMSI,发送携带该身份信息的信令给基站,请求接入运营商网络。...

    5G时代,跟IMSI-CATCHER SAY GOODBYE from:https://unicorn.360.com/blog/2018/04/18/GoodBye_5G_IMSI-Catcher/ ...

  2. 查看Apache服务器的错误log文件

    查看Apache服务器的错误log文件: tail /etc/httpd/logs/error_log

  3. 查看Windows系统安装和卸载驱动的日志信息

    最近在用InstallShield2010开发一个一键打包驱动的项目,需要支持安装和卸载.调试时需要知道驱动安装和卸载功能是否正确执行,可以系统盘的Windows的inf目录中查看这两个文件的信息se ...

  4. 【收藏】为什么在Scala中可以在运行时将AnyVal转换为AnyRef?AnyVal转换为AnyRef

    http://www.voidcn.com/article/p-mpirtzuw-bve.html

  5. 使用ant design vue 中table组件运行时not found: Error: Can't resolve 'reqwest' in 'D:\vue\antd-demo01\src\com

    最近使用table时按照官网api使用table报了上面这个错误 1.只需要安装无法找到文件就可以正常运行了 2.命令行cd进入项目文件 3.运行npm install --save reqwest ...

  6. Eclipse中查看没有源码的Class文件的方法

    本文地址:http://blog.csdn.net/sushengmiyan/article/details/18798473 本文作者:sushengmiyan 我们在使用Eclipse的时候,经常 ...

  7. 如何查看Intel Realsense D435 状态log文件

    First, open up the RealSense Viewer's "Settings" window by left-clicking on the gear-wheel ...

  8. Linux 中执行命令 ls -l 后,文件详细信息(文件属性/文件详情)说明

  9. ATC‘22顶会论文RunD:高密高并发的轻量级 Serverless 安全容器运行时

    编者按:目前的安全容器软件栈 - 包括 host 操作系统中的 cgroup.guest 操作系统和用于函数工作负载的容器 rootfs,都会导致低部署密度和在低并发能力.为此,RunD 作为一种轻量 ...

最新文章

  1. 第一阶段站立会议08
  2. 一个关于Oracle更新语句引发的时间字段类型的问题
  3. python:将32位的16进制数据以二进制/hex/binary的形式写入到文件
  4. 常见的排序算法(1)
  5. [转载]C#中各种计时器
  6. firefox自动化测试的常用插件
  7. .NET 5 自身就是一个 .NET Standard
  8. vue使用better-scroll实现下拉刷新、上拉加载
  9. MSsqlserver服务快速打开和停止
  10. ZetCode PHP Symfony 教程
  11. 腾讯或于本周正式宣布合并搜狗?官方回应:看点招聘及搜狗合并均正常进行...
  12. [CLR团队公告]CLR基础研究团队,邀请您的加入
  13. Linux-网络RAID技术DRBD
  14. 搭建你的Spring.Net+Nhibernate+Asp.Net Mvc 框架 (四)配置全攻略
  15. Map与JSON数据之间的互相转化
  16. 移动端(html5)富文本编辑器,vue移动端中使用vue-html5-editor富文本编辑器详解
  17. SqlServer 2016新特性 —— automatic seeding (自动种子设定)究竟是什么
  18. 视频教程-数字图像处理实战-算法基础
  19. 进程、线程、协程和管程
  20. Go语言占位符的使用

热门文章

  1. c++中的fork函数_fork函数
  2. 【烂笔头】android 左上角三角形 右上角三角形
  3. 2023寒假学习注意
  4. dropout层加在哪里_常用层 - Keras中文文档
  5. iBase4J nginx配置
  6. AE 动效工作流技巧 —— 减少 Bodymovin 导出的 JSON 大小并提升性能(四)
  7. MySQL和POSTGRESQL的常用语法区别
  8. 计算机基础知识教案 技能高考,高考实用类文本阅读知识复习教案
  9. PUSHmall 推贴订货商城系统 — — B2B/B2C批发零售采销模式,商贸流通企业最佳电商解决方案
  10. Eclipse Spring Boot STS安装及下载地址整理