php - 在 Nginx 中显示 PHP 错误而不是 502 Bad Gateway

标签 php error-handling nginx

如何显示 PHP 错误而不是 nginx 的 502 Bad Gateway 错误?我有所有错误报告,但每当我导致 fatal error 时,PHP 错误信息都不会传递给浏览器。

最佳答案

  • 创建一个路由文件来调度 url;
  • 在路由文件中使用 try/catch 捕获所有异常;
  • 捕获异常时显示自定义 502 页面。

  • 例如:
    Nginx 配置:
    error_page 502 http://example.com/502.html;

    关于php - 在 Nginx 中显示 PHP 错误而不是 502 Bad Gateway,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18371460/

    相关文章:

    PHP 将 MySql 查询与类分离

    apache - 设置Apache Web服务器

    t-sql - 我是否必须在 T-SQL 中的 catch block 中回滚事务之前对事务进行计数?

    linux - 在 CentOS linux bash 脚本中回显写入文件时转义美元符号

    php - 拉维尔 5 : Database Migrations (Help! )

    php - 禁用 PHPExcel 中的几个单元格

    c++ - 创建与 nginx 通信的 c++ 应用程序的最佳方法

    AngularJS $http.post() 到同一台机器上的另一个端口

    php - 第 1 行 SQL 语法错误?

    powershell - 如果抛出错误,我如何继续处理项目?