How to create an EC2 instance on AWS for Laravel App

Log into your AWS account, on Services go to EC2 section

Click on Launch Instance button. It will start the wizard. On Step 1 (Choose an Amazon Machine Image) we’re going the select the type of Operating System for our instance. I choose Ubuntu.

Choose an Amazon Machine Image (AMI)
Choose an Amazon Machine Image (AMI)

On step 2 you need to choose an instance type. Choose the t2.micro instance type which is Free-Tier compatible.

Choose an Instance Type
Choose an Instance Type

We can skip the 3rd (Configure Instance Details), 4th (Add Storage), and 5th (Add Tags) steps without changing any of the default parameters since we don’t need for now any additional configuration at this point.

On Step 6 we will Configure a Security Group which is a set of firewall rules that control the traffic for our instance. Click on Add Rule button and select HTTP, and then select HTTPS. These will allow HTTP/HTTPS traffic in and out of the instance, making it accessible over the internet. The first rule, the SSH directive, will enable us SSH into the instance and make necessary updates, configurations, and installation.

Configure Security Group
Configure Security Group

When you finish click on the Review and Launch button. On step 7 (Review Instance Launch) you will find a summary of all settings of your instance. Click on the Launch button and You will be prompted to select or create a new key pair. Select “Create a new key pair” and set a name. Once this is done, download the key pair (make sure you do). Will will be using the downloaded key pair to SSH into our instance shortly.

Click on Launch Instances to finish.

Create a new key pair
Create a new key pair

Extra: How to connect to EC2 w/ PuTTY (Windows)

To get access to your EC2 instance you need to connect through SSH. In my case, I use windows as my base O.S. so I’m going to use Putty to get access to my EC2 instance using the new keypair downloaded.

You need to download Putty and Puttygen.

Open Puttygen and load button and look for the keypair file downloaded when you create the EC2 instance and click OK on the next dialog box.

Load keypair file on Puttygen
Load keypair file on Puttygen

Click on Save private key button and choose the folder on which you want to store it. Set a name for the private key (converted_keypair or the name you want) and Save.

Now Go to our EC2 instance, select the instance, click on connect button and copy the host address and username.

Copy host address and username
Copy host address and username

Open Putty and paste it on Host Name (or IP address) field.

Paste address on host name field
Paste address on host name field

Now, on Connection Category go to Data section and set the user on Auto-login username field.

Set username
Set username

Now expand SSH node and go to Auth section. Click on browse button and look for your converted keypair we did on the first steps.

Select converted keypair
Select converted keypair

Then go to Session category and set a name for your session on Saved Sessions field and click on Save button.

Save session
Save session

Click on Open button to open the connection, if everything was set up correctly you should be immediately logged in to EC2 instance.

EC2 instance
EC2 instance

I hope this can be helpful for anybody.

2 comentarios sobre “How to create an EC2 instance on AWS for Laravel App

  1. I and my buddies were actually analyzing the great guides from your website and so then I had an awful suspicion I never expressed respect to the site owner for those techniques. All of the ladies were definitely absolutely excited to study all of them and already have seriously been taking advantage of those things. Thanks for indeed being considerably thoughtful and also for deciding upon this sort of very good subject areas millions of individuals are really eager to learn about. My sincere regret for not expressing appreciation to you earlier.

Deja un comentario