Preparing a Laravel Project for Production
Moving a Laravel application from local development to a live production server involves more than just uploading files — a handful of steps keep it secure and running smoothly.
Pre-Deployment Checklist
- Set APP_ENV=production and APP_DEBUG=false in .env
- Generate a fresh, strong APP_KEY if one hasn't been set
- Run composer install --optimize-autoloader --no-dev
- Run production asset builds (npm run production or npm run build)
- Run outstanding database migrations
File Permissions
chmod -R 775 storage bootstrap/cache
The storage and bootstrap/cache directories need to be writable by the web server process.
Queue and Scheduler in Production
Production deployments typically run queue workers under a process manager like Supervisor, and rely on the system cron entry for schedule:run covered earlier in this course.
HTTPS and Security Headers
Production traffic should be served over HTTPS, with Laravel's URL generation forced to https using URL::forceScheme('https') if needed behind a load balancer.
Getting these basics right sets the stage for two more focused production topics: managing environment configuration safely, and caching for performance.
Ready to master Laravel Training Course?
Join Uncodemy's hands-on Laravel program and build real, production-ready applications.
