Enable Error Display
In production, PHP errors are typically hidden. For debugging, temporarily enable them:
# In your PHP file (temporary)
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);Check PHP Error Log
# Find the error log location
php -i | grep error_log
# Common locations
tail -f /var/log/php8.2-fpm.log
tail -f /var/log/apache2/error.log
tail -f /var/log/nginx/error.logCommon PHP Errors
500 Internal Server Error
# Check web server error log
tail -20 /var/log/nginx/error.log
# Common causes:
# - Syntax error in PHP file
# - Missing PHP extension
# - Incorrect file permissionsMemory Exhaustion
# Error: Allowed memory size of X bytes exhausted
# Fix: Increase memory_limit in php.ini
memory_limit = 256M
sudo systemctl restart php8.2-fpmMissing Extensions
# Error: Call to undefined function
# Find which package provides the function
apt search php8.2 | grep extension-name
# Install common extensions
sudo apt install -y php8.2-mysql php8.2-curl php8.2-mbstring php8.2-xml php8.2-zip php8.2-gd php8.2-redisPermission Denied
# PHP cannot write to directory
sudo chown -R www-data:www-data /var/www/html/uploads
sudo chmod 755 /var/www/html/uploadsPHP-FPM Status Page
# Enable in pool config (/etc/php/8.2/fpm/pool.d/www.conf)
pm.status_path = /status
# Access via Nginx
location ~ ^/status$ {
allow 127.0.0.1;
deny all;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}Xdebug for Development
sudo apt install -y php8.2-xdebug
# /etc/php/8.2/fpm/conf.d/20-xdebug.ini
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=your-local-ip