nginx showing blank PHP pages

nginx showing blank PHP pages

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

nginx Showing Blank PHP Pages: Diagnosing Silent Failures

When an Nginx server paired with PHP-FPM serves HTML perfectly but renders PHP files as blank white screens, it is rarely a mystery of missing logic in your application code. The issue almost always lies in the configuration handshake between the web server and the FastCGI process manager. In the specific scenario where display_errors is toggled off and logs remain silent, you are looking at a classic "null output" problem: the PHP script executed successfully but returned no data to the browser, or the request failed before execution even began.

A critical clue often missed in these scenarios involves the initial entry point of your application. The provided configuration shows Nginx listening on port 80 and serving files from /home/mike/www/606club. However, the error log reveals a specific failure: open() "/home/mike/www/606club/robots.txt" failed (2: No such file or directory).

This indicates that Nginx is attempting to resolve a request for robots.txt before it ever reaches your PHP handler. While robots.txt is not strictly required for a site to function, many frameworks and CMS installations attempt to serve this file dynamically via PHP when the physical file is missing. If your root directory lacks a static robots.txt, Nginx might be routing the request to index.php. When that script runs without proper error reporting enabled (or if the error handler swallows exceptions), the result is an empty response body.

To resolve this, you must first ensure the physical file exists or explicitly configure Nginx to skip it. Creating a simple robots.txt in your document root is the most robust fix:

# /home/mike/www/606club/robots.txt
User-agent: *
Disallow: /admin/
Allow: /

If you prefer not to create the file, you can adjust the Nginx location block to handle this specific resource before falling back to PHP.

location = /robots.txt {
    default_type "text/plain";
    return 200 "User-agent: *\nDisallow: /\n";
}

Beyond the entry point, there is a deeper architectural consideration regarding how Nginx handles .php files. The configuration snippet uses fastcgi_pass unix:/var/run/php5-fpm.sock;. This is generally correct for modern setups, but it introduces a potential pitfall: socket path mismatches or permission issues. If the PHP-FPM process does not have write permissions to its log file, or if the socket disappears and restarts unexpectedly, Nginx may fail to connect silently depending on error log levels.

However, the most common cause for a completely blank page in this context is that fastcgi_param SCRIPT_FILENAME is being constructed incorrectly relative to the server root, or that SCRIPT_NAME does not match the actual file path. While the provided config includes include fastcgi_params;, which usually handles these variables correctly, you must ensure that your PHP script itself is not exiting early due to a fatal error that is being suppressed.

To diagnose silent failures effectively, temporarily enable error reporting in php.ini within the specific project directory:

display_errors = On
error_reporting = E_ALL
log_errors = On
error_log_path = /home/mike/www/606club/php_errors.log

Restart both services after making changes to ensure the new configuration takes effect without reloading stale state. If errors still do not appear in php5-fpm.log or the custom log, the issue might be that the PHP process is crashing immediately upon initialization (e.g., missing extensions) but Nginx treats this as a 200 OK response with empty content if the status code isn't explicitly checked.

In high-availability environments where you cannot afford downtime to toggle error settings, consider adding fastcgi_read_timeout and fastcgi_send_timeout directives to your Nginx config. These ensure that if the PHP process hangs or dies, Nginx returns a timeout error rather than waiting indefinitely for empty output.

location ~ \.php$ {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
    
    # Prevent hanging on slow PHP scripts
    fastcgi_read_timeout 30s;
    fastcgi_send_timeout 30s;
}

Finally, verify that the fastcgi_param SCRIPT_FILENAME is set correctly. If you are using a relative path in your code expecting an absolute one, the script will fail to execute. Ensure your document root points exactly to where your scripts reside and that the permissions on /var/run/php5-fpm.sock allow the Nginx worker process to read it.

By addressing the missing robots.txt entry point and tightening the FastCGI connection parameters, you eliminate the most frequent causes of silent PHP failures in Nginx environments. If your application framework relies on dynamic resource generation for standard files like robots.txt, ensure that configuration is overridden statically to prevent routing logic from interfering with PHP execution.

Our network