Deploying to Laravel Forge & AWS

Ian Conway
5 min readMay 1, 2020

Follow along as we take a journey through Laravel Forge. In this tutorial, we will learn how to take a Laravel project, and deploy it on Laravel Forge, using tools like AWS and GitHub along the way. We will go through the entire process from start to finish, including creating accounts on each platform.

First things first, what is Laravel Forge?
Laravel Forge is a tool for deploying and configuring web applications, over top platforms like AWS or Digital Ocean. It does not replace your hosting provider.

What tools do I need to follow along?
We will be working with tools like GitHub, AWS, and Laravel Forge, and will be doing so inside a web browser. We will also use the terminal for things like installing our Laravel project, and getting our GitHub repository pushed up.

Are there any costs I need to know about?
That is a great question! First and foremost, Laravel Forge is not a free product, and starts at $12/month for their base “Hobby” plan. Worry not, Laravel Forge offers a five day trial that will get us through today. Another cost to consider is your hosting provider. For this tutorial, we will be using AWS, and will fall under their “Free Tier” plan. Finally, if you want to use a Domain Name, that is a cost to consider as well. While a domain name is optional for today, I would highly recommend getting one eventually.

What are we building today?
In this tutorial, we are going to be deploying a website for a fictitious company named Billy’s Burritos. We will focus on the deployment process, and will not be jumping into any code.

Ok, enough talk, let’s get started.

Setup Your Project

This first part is all about getting a base project setup, so we can deploy it to Laravel Forge. If you have an existing project you’d like to push up, use that instead of following these steps.

  1. Install an empty project with the Laravel Global Installer (use the auth switch at the end of your command to include the Authentication Scaffolding).
laravel new billys-burritos --auth

Get Your Git Going

Next we are ready to get our GitHub account created and our repository ready.

  1. Create a GitHub account on this page here.
  2. Verify your email address by clicking the link from GitHub in your inbox.
  3. Click the green Create Repository button and name your repository appropriately. Also consider if you want to make your repository public or private.

Now that the repository is created, it is time to get the code pushed up.

  1. Change your terminal path into your project, mine is on my desktop so it looks like this:
cd ~/Desktop/billys-burritos

2. Initiate your directory as an empty repository:

git init

3. Add all of the existing files from your project into version control:

git add .

4. Create a commit for all of these files:

git commit -m "First commit"

5. Add the repository origin (be sure to change the bolded part to your information):

git remote add origin https://github.com/user/repo.git

6. Push it all up!

git remote add origin https://github.com/user/repo.git

Time for AWS

Next we are ready to create an AWS account.

  1. Create an AWS account on this page here.
  2. Enter all personal and billing information.
  3. Verify your mobile number.
  4. Subscribe to the Free Tier plan.
  5. Once you are at the home page for your AWS console, click your account name in the top right corner, and then click My Security Credentials.
  6. On the left, click Users and then Add User.
  7. For the username, enter anything you’d like. I would recommend entering forge.
  8. For the Access Type, select Programmatic Access.
  9. The next screen will prompt you to create a group. Create a new group and name it anything you’d like. The bottom part of the screen will allow you the select different security policies from the list. Place a checkmark next to the following two policies: AmazonEC2FullAccess and AmazonVPCFullAccess.
  10. Create the group and click Next through the next two screens, and then click the final Create User button.
  11. Once your user is created, you will be redirected to a screen where you can download the Access Key ID and the Secret Access Key. Click Download .csv to download these credentials. Once you navigate away from this page, you will not be able to see your Secret Access Key again, so download it while you still can.

It’s Forge Time

We have come a long way already, and we are finally ready to get into Laravel Forge.

  1. Create a Laravel Forge account on this page here.
  2. Once your account is created, click Connect GitHub under the Source Control panel, and enter your GitHub credentials to connect.
  3. Under the Server Providers panel, click AWS and enter in the Access ID and Secret Key from the downloaded .csv file from AWS into these fields.
  4. Click Subscribe to billing plan and enter your payment information. Then click Subscribe under the base “Hobby” plan.
  5. Under the Create Server panel, click AWS and fill in the following fields to create your server:
  6. Server Name: This can be anything you want, or you can leave it set to the default randomly generated name.
  7. Server Size: Leave this set to the default to ensure you fall under the AWS free tier plan.
  8. VPC Name: This can be anything you want, I typically copy the same name as the server name here.
  9. Any other fields can be left as their default. Once you click Create Server, you will be it can take some time to setup and provision your server. Once it has finished provisioning, you can move onto the next step.
  10. Once the server is finished provisioning, you should be redirected into the server page. If you are not, you can click Servers from the main menu at the top, and then click on the name of your server from the dropdown list.
  11. The first thing you will need to do on the server is create a new Site to link your repository. Enter your domain name in the Root Domain field, and check Create Database if your application will be using a database. Then, click Add Site.
  12. Your new site will populate into the list of Active Sites at the bottom of the page. Click the name of your site from the list.
  13. Next, you will be prompted to link your git repository. Enter your username followed by your repository name, and leave the branch field set to Master.
  14. When you’re ready, click Install Repository.

DNS Mind If I Do

This is the last leg of the journey. If you are not using a domain name, you can skip this section.

  1. Log into your Domain Name provider, like GoDaddy.
  2. Update your main A Record to point to the IP Address of your new Laravel Forge server. You can find this IP Address at the top of any server or site page.

Test It Out

The time has come to test it out. Go ahead and try for yourself!

--

--