Nginx如何开启PHP错误提示
2022-12-02 09:01:16
132
{{single.collect_count}}

Nginx开启PHP错误提示的方法:首先要编辑php配置文件;然后编辑nginx的fpm配置文件为“php_admin_flag[log_errors] = on”;最后重启php-fpm和nginx即可。

php入门到就业线上直播课:进入学习
Apipost = Postman + Swagger + Mock + Jmeter 超好用的API调试工具:点击使用

推荐:《PHP视频教程

在使用nginx的过程中总是会碰到nginx提示500错误,可是具体错误需要去查看错误日志文件, 很是不方便。打开错误页面提示很实用于调试PHP的时候,但不建议在线服务器开启此功能

关于PHP的配置文件fpm模式和cli模式可能是两个配置文件,需要2个都修改

CLI模式执行命令

php phpinfo.php
登录后复制

查看环境变量

Server API => Command Line InterfaceVirtual Directory Support => disabledConfiguration File (php.ini) Path => /etc/php/7.2/cliLoaded Configuration File => /etc/php/7.2/cli/php.iniScan this dir for additional .ini files => /etc/php/7.2/cli/conf.d
登录后复制

首先要编辑php配置文件:

vi /etc/php.inierror_reporting = E_ALLdisplay_errors = On
登录后复制

因为我开启了php-fpm。所以还要编辑 nginx的fpm配置文件

vim /etc/php5/fpm/pool.d/www.confphp_flag[display_errors] = on;php_admin_value[error_log] = /data/www/log/error.log ;php_admin_flag[log_errors] = on
登录后复制

重启php-fpm和nginx。这样在开发的时候就可以在浏览器中显示php出现的错误了,非常方便

以上就是Nginx如何开启PHP错误提示的详细内容,更多请关注php中文网其它相关文章!

回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}