Laravel security checklist for your own Ubuntu or Debian server
Laravel comes with strong defaults against SQL injection and CSRF, yet most real-world breaches on self-hosted Laravel servers come from server setup mistakes: APP_DEBUG=true left on, Nginx pointing above /public so .env is downloadable, or outdated Composer packages. Check these seven things today.
APP_DEBUG=false in production, point Nginx strictly to Laravel's public/ folder, lock .env to permissions 600, run composer audit, and keep queue workers running as an unprivileged deploy user.1. Check APP_DEBUG and APP_ENV in production
When APP_DEBUG=true is left on in production, a single 500 error page can print database credentials, APP_KEY, and stack traces to any visitor. Check your production .env right now:
APP_ENV=production
APP_DEBUG=false
After changing .env, rebuild the config cache cleanly (php artisan config:cache). See how to debug Laravel 500 errors safely via logs without turning debug pages on in public.
2. Point Nginx strictly at Laravel's public/ folder
Your Nginx root must always end in /public — never the project root folder. If Nginx points to the project root, anyone opening https://yoursite.example/.env in a browser can read your database password and APP_KEY directly.
Double-check your Nginx site file and test curl -i https://yoursite.example/.env to confirm it returns 403 or 404. Need a clean layout reference? Follow deploying Laravel on your own server.
3. Lock down .env and storage ownership
Keep .env readable only by the site's PHP-FPM / deploy user (never world-readable):
chmod 600 /var/www/your-app/.env
chmod -R ug+rwX /var/www/your-app/storage /var/www/your-app/bootstrap/cache
And make sure storage/app/public/ does not allow direct execution of uploaded .php files if users can upload avatars or documents. Review PHP site file permissions on Ubuntu and Debian for details.
4. Run composer audit before every deploy
Laravel relies on dozens of Composer packages (Livewire, Symfony components, HTTP clients). Check your composer.lock for known CVEs regularly:
composer audit --locked
Keep composer.lock committed and follow our guide to keeping Composer packages safe and up to date.
5. Secure Laravel Horizon, Telescope and queues
Debugging dashboards like Laravel Telescope and queue monitors like Horizon should require explicit gate checks in production (Horizon::auth(...)) and must never remain open to unauthenticated traffic. Keep workers running cleanly under systemd as a non-root user using running Laravel Horizon with systemd.
6. Add HTTPS, rate limits and automatic OS updates
Put login, password reset, and API routes behind Laravel rate limiters (ThrottleRequests), enforce HTTPS cleanly, and enable automatic security updates on Ubuntu and Debian so OpenSSL, Nginx, and PHP patches arrive on time.
Server hardening covers your OS and Nginx setup, while testing custom Laravel permissions and API logic (such as checking whether one user can read another user's records) calls for a manual penetration test like SecurityNest.
Managing Laravel apps across multiple VPS hosts? ServerNest keeps PHP updates, Horizon/queue checks, and SSL alerts in one place — Sign up to try it.