When Laravel throws a 500, you’ll need to trace it through three layers: Laravel itself, Nginx, and PHP-FPM. Here’s where to look and how to pinpoint the issue.
1. Turn on Laravel Debug
- Open your project’s
.env file.
- Set
APP_DEBUG=true APP_ENV=local
- Save and reload your page.
– You should now see a detailed stack trace instead of the generic 500 page.
2. Inspect Laravel Logs
Laravel logs errors in storage/logs. Usually you’ll find:
cd /home/mailivery/mailivery
ls storage/logs
tail -n 50 storage/logs/laravel.log
– Look for the latest timestamped file (laravel-YYYY-MM-DD.log).
– Errors, exceptions, SQL problems and failed queue jobs all land here.
3. Check Nginx Error Logs
By default Nginx writes to:
/var/log/nginx/error.log
Or, if you have a per-site config:
/var/log/nginx/your-site-error.log
Tail it live as you refresh:
sudo tail -f /var/log/nginx/error.log
Common culprits: wrong root path, missing index.php, bad fastcgi_pass.
4. Review PHP-FPM Logs
Depending on your PHP version, you’ll have one or more of:
/var/log/php7.4-fpm.log
/var/log/php8.1-fpm.log
Or check the pool-specific log in /etc/php/8.1/fpm/pool.d/www.conf for error_log.
Tail it:
sudo tail -f /var/log/php8.1-fpm.log
Look for PHP parse errors, call-stack dumps, or FPM pool failures.
5. Verify File & Folder Permissions
Laravel needs write access to storage/ and bootstrap/cache:
cd /home/mailivery/mailivery
sudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R 750 storage bootstrap/cache
If PHP-FPM runs as a different user, swap www-data accordingly.
6. Final Tips & Next Steps
- Use Laravel’s
Log::info() or dd() to pinpoint logic errors.
- Install Laravel Telescope or Sentry for deeper runtime telemetry.
- If you suspect opcache or stale files, restart PHP-FPM:
sudo service php8.1-fpm restart
- For systemd-enabled servers, view FPM via
journalctl -u php8.1-fpm.
Once you find the first error line in Laravel’s log or PHP-FPM’s stack, you’ll know exactly what to fix. Happy debugging!