Getting Started with Laravel Forge


Laravel Forge is a server management and deployment platform that makes it incredibly easy to deploy and manage Laravel applications. In this guide, I’ll walk you through getting your first application deployed.

What is Laravel Forge?

Forge handles the tedious parts of server management so you can focus on building your application. It provisions servers, manages deployments, handles SSL certificates, and much more.

Prerequisites

Before getting started, you’ll need:

  • A Laravel Forge account
  • A server provider account (DigitalOcean, AWS, Linode, etc.)
  • A Laravel application in a Git repository

Creating Your First Server

  1. Connect your server provider: In Forge, navigate to your server providers and connect your DigitalOcean, AWS, or other provider account.

  2. Provision a new server: Click “Create Server” and select your provider, server size, and region. Forge will automatically provision and configure the server with everything you need (Nginx, PHP, MySQL, Redis, etc.).

  3. Wait for provisioning: This typically takes 5-10 minutes. Forge will install and configure all the necessary software.

Deploying Your Application

Once your server is ready:

  1. Create a new site: Navigate to your server and click “New Site”

  2. Configure your site: Enter your domain name and select your project type (Laravel)

  3. Connect your repository: Link your Git repository (GitHub, GitLab, or Bitbucket)

  4. Install repository: Forge will clone your code and run composer install

  5. Configure environment: Update your .env file with your production settings

  6. Run migrations: Use the Forge UI to run your database migrations

Setting Up Deployments

Forge makes continuous deployment simple:

  1. Navigate to your site’s “Apps” tab
  2. Enable “Quick Deploy” to automatically deploy when you push to your main branch
  3. Customize your deployment script if needed

Your deployment script might look like:

cd /home/forge/your-site.com
git pull origin main
composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan queue:restart

Next Steps

Now that your application is deployed, you might want to:

  • Set up SSL certificates (Forge makes this one-click with Let’s Encrypt)
  • Configure scheduled jobs
  • Set up queue workers
  • Add deployment notifications

Forge handles the infrastructure so you can focus on building great applications.