DEV Community

Cover image for Deploying a Laravel Application on Laravel Forge with AWS | Step-by-Step Guide
Buddhi Eashwarage
Buddhi Eashwarage

Posted on • Originally published at

Deploying a Laravel Application on Laravel Forge with AWS | Step-by-Step Guide

Deploying a Laravel application to the cloud can be a complex and time-consuming process. However, with the help of Laravel Forge and AWS (Amazon Web Services), developers can streamline this deployment process and ensure a smooth transition from development to production. In this article, we will walk you through the steps to deploy a Laravel application from GitHub to AWS using Laravel Forge.


Before we dive into the deployment process, make sure you have the following prerequisites in place:

A Laravel application hosted on GitHub.
An AWS account with proper IAM permissions to create and manage resources like EC2 instances, databases, and S3 buckets.
A Laravel Forge account.

Step 1: Set Up Laravel Forge

Sign in to your Laravel Forge account or create a new one if you haven't already done so.

Once logged in, click on the "Connect to a Server" button and follow the instructions to add your AWS account. This process will allow Laravel Forge to manage AWS resources on your behalf.

Now, connect your GitHub account to Laravel Forge. Head to "Sites" and click on the "Create Site" button. Select "GitHub" as the Git provider and follow the prompts to authorize the connection.

Step 2: Create a New Server

After connecting to your GitHub account, click on the "Create Server" button in Laravel Forge.

Choose AWS as the cloud provider and select your desired region.

Next, select your preferred server size, PHP version, and other configurations according to your application's requirements.

Laravel Forge will handle server provisioning and automatically configure PHP, Nginx, and other necessary software.

Bonus TIP 1 - Sometimes you may be encounter with an issue when creating the server due to AWS default security group's limitation of the inbound rules for provisioning a server with Laravel Forge. If that's the case, make sure to create a new security group with the following inbound rules and attach that security group to the EC2 instance created by Forge. Refer to this link for the latest documentation on this -

Step 3: Configure the Environment and Database

While creating the server, you can set up environment variables required for your Laravel application. These can include database credentials, API keys, and other sensitive information.

Create a new database server through Laravel Forge or connect to your existing AWS RDS instance.

Step 4: Deploy Your Laravel Application

Once your server is ready, go to the "Sites" section in Laravel Forge and click on the site you created.

Choose the GitHub repository that contains your Laravel application.

Select the branch you wish to deploy (usually the master branch).

Click "Deploy Now" to trigger the deployment process. Laravel Forge will clone your repository, install dependencies, and run any necessary migration commands.

Step 5: Set Up SSL (Optional)

Laravel Forge allows you to easily secure your application with SSL certificates. You can either use a free Let's Encrypt certificate or upload a custom SSL certificate.

Head to the "Security" tab of your site and choose your preferred SSL option.

Step 6: Monitor and Scale

Laravel Forge provides useful monitoring and notification features. You can set up notifications for deployment failures, server outages, and other critical events.

As your application grows, you can easily scale your AWS infrastructure by adding more servers or optimizing the existing ones.

Bonus TIP 2 - If you like to refer to a video tutorial on this, please check the following video:

Deploying a Laravel application from GitHub to AWS using Laravel Forge offers developers a straightforward and efficient way to move their projects from development to production.

With Laravel Forge handling server provisioning, environment configuration, and application deployment, developers can focus on building and improving their Laravel applications without worrying about the underlying infrastructure.

By combining the power of Laravel Forge and AWS, developers can ensure a reliable and scalable environment for their Laravel applications.

Top comments (0)