Skip to main content

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.

 

Prerequisites

 

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 - https://forge.laravel.com/docs/1.0/servers/providers.html#amazon-aws-api-access

 

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.


Comments

Popular posts from this blog

Building a Menu Bar Desktop Application with NativePHP package in Laravel

NativePHP  package recently introduced and in Laravel it allows us to design and develop cross platform desktop applications. It has inherited from Electron project. In this blog post I'll show how to come-up with a desktop application using Laravel with Blade templates. Create a new Laravel Project using composer composer create-project laravel/laravel laravel-native-php Installing NativePHP package composer require nativephp/electron Run php artisan command in the terminal to check what are the next NativePHP related commands to be executed. We can see that there is a command to be executed call native:install which will install NativePHP by creating a separate AppServiceProvider for it. As you can see once executed php artisan native:install command, you'll see it prompts for choosing options for two questions. We just need to select yes for installing the NativePHP NPM dependencies, and select no for starting the NativePHP development server. After this point everything

Microsoft's AZ-900: Empowering the Cloud Journey with Azure Fundamentals

In today's digitally-driven world, the cloud has become the backbone of modern technology, powering countless businesses and organizations across the globe. Microsoft, a pioneer in the tech industry, recognized the growing importance of cloud computing early on and has developed a comprehensive certification program to equip individuals with the necessary knowledge to harness the power of the cloud. The Exam AZ-900: Microsoft Azure Fundamentals is the gateway to understanding and leveraging the potential of Microsoft Azure. Even more enticingly, Microsoft offers this certification along with free training, making it accessible to anyone aspiring to thrive in the cloud ecosystem. Unlocking the Potential of Azure with AZ-900 The Microsoft Azure Fundamentals (AZ-900) exam is designed for individuals who are new to the cloud domain or those looking to validate their fundamental knowledge of cloud concepts. The exam covers foundational topics, such as cloud computing concepts, core Azur