Pre-deployment checklist
Before deploying to production, ensure you have:Environment configured
Production
.env file with secure credentialsDatabase ready
Production database server configured and accessible
Domain setup
Domain name configured with SSL certificate
Backups planned
Database and file backup strategy in place
Environment configuration
Production environment file
Create a production.env file with these critical changes:
.env
Critical environment variables
Must be set to
production to disable debug mode and enable optimizationsMust be
false in production to prevent sensitive information leaksGenerate with
php artisan key:generate. Used for encryption and securityUse
mysql or pgsql for production. SQLite is not recommended for productionDeployment steps
Install dependencies
Install PHP and Node.js dependencies:
The
--no-dev flag excludes development dependencies, reducing the deployment size.Build frontend assets
Compile and optimize frontend assets:This creates optimized production builds of your CSS and JavaScript.
Optimize application
Run Laravel optimization commands:These commands cache configuration, routes, and views for better performance.
Set file permissions
Configure proper file permissions:Adjust
www-data to match your web server user.Configure web server
Point your web server to the
public directory. See the hosting guide for specific configurations.Performance optimizations
Enable OPcache
Enable PHP OPcache for significant performance improvements:php.ini
Use Redis for caching
Redis provides better performance than file-based caching:.env:
Database optimization
For MySQL/MariaDB, optimize your database configuration:Security best practices
Use HTTPS
Use HTTPS
Always use HTTPS in production. Obtain a free SSL certificate from Let’s Encrypt:
Configure CORS
Configure CORS
If your API is accessed from different domains, configure CORS properly in
config/cors.php.Rate limiting
Rate limiting
The application includes rate limiting on authentication routes. Monitor and adjust as needed in
routes/auth.php.Database credentials
Database credentials
Use a dedicated database user with minimal permissions:
File permissions
File permissions
Ensure sensitive files are not publicly accessible:
Monitoring and logging
Application logs
Configure logging for production in.env:
storage/logs/laravel.log.
Laravel Telescope
config/telescope.php
app/Providers/TelescopeServiceProvider.php.
Health checks
Set up a health check endpoint for monitoring:routes/web.php
Backup strategy
Database backups
Schedule regular database backups:File backups
Backup uploaded files and important directories:Zero-downtime deployment
For zero-downtime deployments, use tools like:- Laravel Envoyer - Official Laravel deployment service
- Deployer - PHP deployment tool
- GitHub Actions - Automated CI/CD pipeline
.github/workflows/deploy.yml
Troubleshooting
500 Internal Server Error
500 Internal Server Error
Check Laravel logs in
storage/logs/laravel.log and ensure:.envfile exists and is readableAPP_KEYis set- Database connection is configured correctly
- File permissions are correct on
storageandbootstrap/cache
Asset files not loading
Asset files not loading
Run
npm run build and ensure:- Vite manifest exists in
public/build - Web server serves files from the
publicdirectory APP_URLmatches your domain
Session not persisting
Session not persisting
Ensure:
SESSION_DRIVER=databasein.env- Sessions table exists (run migrations)
SESSION_DOMAINis configured correctly for your domain
Email not sending
Email not sending
Verify:
- Mailtrap API key is correct
MAIL_FROM_ADDRESSis valid- Check logs for SMTP errors
Next steps
Hosting options
Explore different hosting solutions for Cashify
Configuration
Learn more about environment configuration