How to Deploy a Laravel Application

How to Deploy a Laravel Application

Step-by-step guide to deploying Laravel applications to production

Subash Rijal
Subash Rijal
Software Developer
March 1, 2025
1 min read
Share:

Table of Contents

Deploying Laravel Applications

This tutorial covers different methods to deploy Laravel applications to production environments.

1. Shared Hosting Deployment

  1. Upload files via FTP/SFTP
  2. Set proper permissions:
   chmod -R 755 storage
   chmod -R 755 bootstrap/cache
  1. Configure .env file with production settings
  2. Run migrations:
   php artisan migrate --force

2. VPS Deployment with Forge

  1. Create new server in Laravel Forge
  2. Configure environment variables
  3. 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
  1. Enable automatic deployments

3. Docker Deployment

  1. 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}
  1. Build and run:
   docker-compose -f docker-compose.prod.yml up -d --build

4. Serverless with Laravel Vapor

  1. Install Vapor CLI:
   composer require laravel/vapor-core
  1. Configure AWS credentials
  2. Deploy:
   vapor deploy production

Choose the method that best fits your project requirements!

Related Posts

Continue your learning journey with these handpicked articles

Fork Yeah! Asynchronous PHP Like a Pro
Tutorials

Fork Yeah! Asynchronous PHP Like a Pro

Master asynchronous programming in PHP with process forking - a comprehensive guide to building concurrent applications

5 min read
Read More →
How to Deploy a Laravel Application on AWS EC2
Tutorials

How to Deploy a Laravel Application on AWS EC2

A comprehensive guide to deploying your Laravel application on an AWS EC2 instance, covering server setup, database configuration, and deployment best practices.

4 min read
Read More →
How I Built an AI Assistant That Writes Weekly Marketing Emails from Sales Data
Tutorials

How I Built an AI Assistant That Writes Weekly Marketing Emails from Sales Data

Learn how to automate your marketing emails using Python, OpenAI GPT, and Google Sheets API to transform sales data into engaging content.

4 min read
Read More →