Share:
Table of Contents
Deploying Laravel Applications
This tutorial covers different methods to deploy Laravel applications to production environments.
1. Shared Hosting Deployment
- Upload files via FTP/SFTP
- Set proper permissions:
chmod -R 755 storage
chmod -R 755 bootstrap/cache
- Configure
.envfile with production settings - Run migrations:
php artisan migrate --force
2. VPS Deployment with Forge
- Create new server in Laravel Forge
- Configure environment variables
- Set up deployment script:
cd /home/forge/your-site.com
git pull origin main
composer install --no-interaction --prefer-dist --optimize-autoloader
npm ci && npm run production
php artisan migrate --force
- Enable automatic deployments
3. Docker Deployment
- Create
docker-compose.prod.yml:
version: '3'
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "8000:8000"
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
- Build and run:
docker-compose -f docker-compose.prod.yml up -d --build
4. Serverless with Laravel Vapor
- Install Vapor CLI:
composer require laravel/vapor-core
- Configure AWS credentials
- Deploy:
vapor deploy production
Choose the method that best fits your project requirements!