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
-
Connect your server provider: In Forge, navigate to your server providers and connect your DigitalOcean, AWS, or other provider account.
-
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.).
-
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:
-
Create a new site: Navigate to your server and click “New Site”
-
Configure your site: Enter your domain name and select your project type (Laravel)
-
Connect your repository: Link your Git repository (GitHub, GitLab, or Bitbucket)
-
Install repository: Forge will clone your code and run
composer install -
Configure environment: Update your
.envfile with your production settings -
Run migrations: Use the Forge UI to run your database migrations
Setting Up Deployments
Forge makes continuous deployment simple:
- Navigate to your site’s “Apps” tab
- Enable “Quick Deploy” to automatically deploy when you push to your main branch
- 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.