Understanding 500 Errors
A generic "something went wrong" error. The real cause is in logs.
Step 1: Check Error Logs
# Nginx
sudo tail -f /var/log/nginx/error.log
# Apache
sudo tail -f /var/log/apache2/error.log
# PHP-FPM
sudo tail -f /var/log/php*-fpm.log
# Application logs (WordPress, Laravel, etc.)
sudo tail -f /var/www/your-site/storage/logs/laravel.log
Common PHP Causes
Parse Errors
Syntax errors in code:
php -l /path/to/suspicious-file.php
Memory Limit Exhausted
Increase in php.ini:
memory_limit = 256M
Caching Issues
# Clear opcache
sudo systemctl restart php*-fpm
# Clear application cache (Laravel)
php artisan cache:clear
php artisan config:clear
File Permissions
# WordPress
sudo chown -R www-data:www-data /var/www/wordpress
sudo find /var/www/wordpress -type d -exec chmod 755 {} ;
sudo find /var/www/wordpress -type f -exec chmod 644 {} ;
WordPress Specific
Increase memory in wp-config.php:
define('WP_MEMORY_LIMIT', '256M');
Disable plugins via FTP:
mv /var/www/wordpress/wp-content/plugins/plugin-name /var/www/wordpress/wp-content/plugins/plugin-name-disabled
Enable PHP Error Display (Temporary)
# At top of index.php
ini_set('display_errors', 1);
error_reporting(E_ALL);