Nginx配置什么原因导致php错误不提示

2024年06月05日 建站教程

哪些Nginx配置会导致php错误不提示,下面web建站小编给大家简单介绍一下具体解决方法!

正确配置方法:

server {
  # server settings
  ...
   
  # server block location rules
  ...
  
  # php-fpm status check
  location ~ ^/(status|ping)$ {
    access_log off;
    # php-fpm settings
    fastcgi_param PHP_VALUE "error_reporting=E_ALL";
    include fastcgi_params;
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
  }
  
  # php error logs
  location ~ \.php$ {
    fastcgi_param PHP_VALUE "error_log=/var/log/nginx/php_error.log";
    include fastcgi_params;
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
  }
  
  # error pages
  error_page 404 /404.html;
  error_page 500 502 503 504 /50x.html;
  
  # static files
  location ~* \.(jpg|jpeg|gif|png|css|js|ico)$ {
    expires 7d;
    access_log off;
  }
  
  # disable direct access to .ht files
  location ~ /\.ht {
    deny all;
  }
}

PS:错误输出地址:/var/log/nginx/php_error.log

本文链接:http://so.lmcjl.com/news/5969/

展开阅读全文
相关内容