Black Friday: coupon FRIDAY24 for 40% off Yearly/Lifetime membership! Read more here
Courses

Deploy Laravel Project to AWS EC2: Step-By-Step

Requirements and New EC2 Instance

So, we need to set up the AWS server for our Laravel project. Let's start with the requirements - for Laravel as a framework, and for our project specifically.


Laravel Server Requirements

According to Official Documentation we have following server requirements:

  • PHP >= 8.0
  • BCMath PHP Extension
  • Ctype PHP Extension
  • cURL PHP Extension
  • DOM PHP Extension
  • Fileinfo PHP Extension
  • JSON PHP Extension
  • Mbstring PHP Extension
  • OpenSSL PHP Extension
  • PCRE PHP Extension
  • PDO PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

Our Demo Project Requirements

These dependencies may vary depending on what your project actually needs or what organization plans to use, but for now, let's stick to the list below to save you a bit of time in the future:

  • NginX HTTP Server
  • PHP-FPM
  • Zip PHP Extension
  • GD PHP Extension
  • PHP CLI
  • Composer
  • MySQL PHP Extension
  • Amazon RDS as MySQL server

Setup EC2 instance

  1. First you need to have an AWS account, sign in or register at https://aws.amazon.com/. We won't go into the registration process itself.
  2. When you log in it should look something like this:

Console Home

  1. Click on the EC2 link in the top bar.

Alternatively, you can find it in the Services menu under Compute category:

Services Compute EC2

  1. Now you should be in your EC2 Dashboard, it looks like that:

EC2 Dashboard

  1. In the top right corner, you need to choose your region first. All the stats dashboard is displaying are for this selected region including your servers (instances). Pick the one which seems most suitable for your user base as it affects how fast it can be reached. In this example, we used Europe (Frankfurt) eu-central-1.

Region

  1. On the second row of the dashboard, there is a card named Launch instance. Your servers are called instances on EC2. Click on the Launch instance button to proceed.

Launch Instance

  1. Enter a name for your server, e.g. Demo web server

Server Name

  1. Choose an OS image. We picked Ubuntu because it provides tools out of the box, and doesn't need any custom installation of packages.

The image was left unchanged, other images are for more specific scenarios.

OS Image

  1. For tutorial purposes we left the t2.micro instance type unchanged, since we do not need more power for demo purposes, also it is a free tier.

According to your project requirements, you might want to change this setting to something more powerful.

Instance Type

  1. To access created instance later you're going to need the SSH key for the server.

Press Create new key pair button:

Key Pair Login

Enter a unique key pair name and select the following options:

  • Key pair type: RSA
  • Private key file format: .pem

Create Key Pair

And press Create key pair on the bottom right corner of the dialog to save and download the key.

Your newly generated key will be automatically downloaded:

Downloaded Key

  1. In network settings choose My IP, to allow access only from your IP Address, sometimes you might want to leave it from Anywhere but it is not recommended or add your custom rules.

Check both Allow HTTPS traffic from the internet and Allow HTTP traffic from the internet, since we are setting a web server and want connections to be accepted on 80 and 443 ports by default.

Network Settings

  1. Then you might want to configure your storage to add more or bigger volumes for your data. We left that unchanged for this tutorial.

Configure Storage

  1. No changes are needed in the Advanced details section. Review the summary in the right sidebar, and press the Launch Instance button in the bottom right corner.

Summary

After that you should see that launch successfully initiated:

Launch Instance Success

avatar

I've always found the interface for Amazon AWS very daunting but your steps made this setup process simple thanks!

๐Ÿ‘ 4
avatar

great, Thanks Povilas

avatar

Currently I am using docker to build local environment, so for this course, do I need docker when deploying?

๐Ÿ‘ 1
avatar

No, this course doesn't use Docker at all, only AWS tools.