1. The Diagnostic First Step: WP_DEBUG
Before you touch a single plugin, you need to see the actual PHP error. The “White Screen of Death” is usually just a suppressed fatal error.
- The Fix: Edit your
wp-config.phpand enable logging:PHPdefine( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false ); - Pro Tip: By setting
WP_DEBUG_DISPLAYto false, you keep the errors out of the public eye while writing them to/wp-content/debug.logfor your review.
2. Resolving 504 Gateway Timeouts
A 504 error usually means NGINX is waiting for PHP-FPM to finish a task, but PHP is taking too long.
- The Diagnosis: Check the NGINX error log. You’ll likely see “upstream timed out.”
- The Fix: Increase the
fastcgi_read_timeoutin your NGINX server block and match it with themax_execution_timein yourphp.ini. - The Root Cause: Often, this is caused by a slow third-party API call or a massive database query that isn’t indexed.
3. Fixing “Error Establishing a Database Connection”
This is rarely a “random” error. It means the PHP process cannot authenticate with MySQL.
- The Checklist:
- Check the Service: Is MySQL running? (
sudo systemctl status mysql) - Check Credentials: Are the DB_USER and DB_PASSWORD in
wp-config.phpcorrect? - Check the Prefix: Did the database prefix change during a migration?
- Check Disk Space: If your VPS disk is 100% full, MySQL will crash and refuse to start.
- Check the Service: Is MySQL running? (
4. Memory Exhaustion Errors
“Allowed memory size of X bytes exhausted.” This happens when a process tries to exceed the allocated RAM for PHP.
- The Fix: Increase the limit in
wp-config.php:define( 'WP_MEMORY_LIMIT', '256M' );. - The Structural Fix: If this keeps happening, use a profiler like Query Monitor or Xdebug to find the specific plugin or function that is leaking memory.
5. Permission and Ownership Conflicts
If you can’t upload images or update plugins, your server’s file ownership is likely mismatched.
- The Fix: Ensure the web server user (
www-data) owns the files.Bashsudo chown -R www-data:www-data /var/www/html find . -type d -exec chmod 755 {} \; find . -type f -exec chmod 644 {} \; - The “Internal” Fix: Check if
DISALLOW_FILE_MODSis set totruein your config, as this will block all updates regardless of permissions.