1
server {
    listen 80 ;
    listen [::]:80 ;
    server_name php.local.com;

    root   /var/www/html/php/;
    index  index.php;
    error_log /var/www/html/php/error.log;

    # set expiration of assets to MAX for caching
        location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
                expires max;
                log_not_found off;
        }
    # main codeigniter rewrite rule
    location / {
        try_files $uri $uri/ /index.php;
    }

        # php parsing
        location ~ .php$ {
            root           /var/www/html/php/;
            try_files $uri =404;
            fastcgi_pass   unix:/var/run/php/php7.1-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  
            $document_root$fastcgi_script_name;
            include        fastcgi_params;
            fastcgi_buffer_size 128k;
            fastcgi_buffers 256 4k;
            fastcgi_busy_buffers_size 256k;
            fastcgi_temp_file_write_size 256k;
        }

}

Its showing error in log but not on browser.

Example of Error :

2019/08/06 01:28:13 [error] 14325#14325: *1 FastCGI sent in stderr: "PHP message: PHP Parse error: syntax error, unexpected '?>' in /var/www/html/php/scalar_type.php on line 18" while reading response header from upstream, client: 127.0.0.1, server: php.local.com, request: "GET /scalar_type.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.1-fpm.sock:", host: "php.local.com", referrer: "http://php.local.com/"

  • 1
    Have you set the `display_errors` PHP config? How about `error_reporting`? – Jonnix Aug 05 '19 at 20:29
  • 1
    Possible duplicate of [Showing all errors and warnings](https://stackoverflow.com/questions/5438060/showing-all-errors-and-warnings) – Jonnix Aug 05 '19 at 20:30
  • @Jonnix error_reporting( E_ALL ); ini_set( "display_errors", 1 ); – Deepak Kumar Aug 05 '19 at 20:32
  • A note, I doubt it will hit the `ini_set` in code if you're getting syntax errors since the code won't run. Better to put it in the `php.ini` of the SAPI you're using. – Jonnix Aug 05 '19 at 20:34
  • Might make sense depending.. it a PHP error or a fastCGI error? Does `echo 5/0;` result in the same? FWIW: [PHP Errors (via FastCGI) with Nginx on Ubuntu Linode](https://serverfault.com/questions/359399/php-errors-via-fastcgi-with-nginx-on-ubuntu-linode) – ficuscr Aug 05 '19 at 20:37
  • Possible duplicate of [How do I get PHP errors to display?](https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display) – Matt Raines Aug 05 '19 at 21:02

0 Answers0