title: 500 error page nginx
body: <p>Over the last days I've been trying to get a 500 page to work, first I had used the same thing I used with error 404 but that didn't work, and I think it's because it's a .php file</p>
  
  <pre><code>error_page 404 /errors/404.php;
  error_page 500 502 503 504 /errors/500.php;
  </code></pre>
  
  <p>Is there any way to use a php file as the 500 error or do I have to create a "500.html" and replicate all the code to be a similar page to the website?</p>
  
  <p>To create a 500 error I used:</p>
  
  <pre><code>fastcgi_pass unix:/var/run/php-fpm/php-fpm.soc;
  instead of fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
  </code></pre>
  
  <p>With the 500.html the error appears, but with the .php it doesn't, this one is logic, because i change the config to run php files, but in php errors doesn't work either.</p>
  
  <p>edit:</p>
  
  <p>domain.com.conf:</p>
  
  <pre><code>server {
      listen       80;
      server_name  www.domain.com;
  
      root   /var/www/domain.com/www;
      index index.php index.html index.htm;
  
      location / {
          try_files $uri $uri.html $uri/ @extensionless-php;
      }
  
      location @extensionless-php {
          rewrite ^(.*)$ $1.php last;
      }
  
      error_page 404 /errors/404.php;
      error_page 500 502 503 504 /errors/500.php;
  
      location ~ \.php$ {
          try_files $uri =404;
          fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
          include fastcgi_params;
      }
  }
  </code></pre>
  
  <p>500.php:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
          &lt;head&gt;
                  &lt;?php include_once '../meta.php'; ?&gt;
                  &lt;?=meta500?&gt;
                  &lt;?php include_once '../header.php'; ?&gt;
                  &lt;title&gt;&lt;?=title500?&gt;&lt;/title&gt;
          &lt;/head&gt;
          &lt;body&gt;
                  &lt;?php include_once("../analyticstracking.php") ?&gt;
                  &lt;?php include_once '../nav.php'; ?&gt;
                  &lt;?php include_once 'containerError500.php'; ?&gt;
          &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This works with the 404 page and all the others pages.</p>