AutoDeploy Laravel Application to EC2 With Single Command [ ./automated_setup.sh]

Akshay Krison
4 min readApr 27, 2022

Are you Fed-up with Server Configurations? This will Reduce the Bulk configuration to be fast by one command to Install php, Php Extensions, Nginx, Mysql...ect

“Developer Friendly Deployment Doc’s”

This article is focused on the deployment of Laravel Application in AWS EC2 with only 1 command in simple developer-friendly configurations for demo purposes.

Prerequisites to Proceed Further

  1. A Laravel Application code needed
  2. Very Basic in Linux Commands
  3. Need an EC2 instance

Deploy the Laravel APP to EC2 By Single Command

You need a Working Laravel App in git to do this, Login to the AWS console and search or Navigate to the EC2 console below shown image and click on the create instance for creating a server. Next you have to create an EC2 Instance for that click on the Launch Instance

Next You have to choose the instance type you need since the AWS provide t2 micro as low server i choose that one( can be upgrade the instance type later) then next go to the Key Pair Section and You can create a new key pair and download it [NB: The Downloaded keypair must be keep safe to login the server in life time] after that allow the HTTP and HTTPS in Network Settings.

After completing all the above steps Click on the Launch Instance to Launch the server and go to the instance page and click on the instance and click the connect button form the top right corner as like the below image shows

Then you will redirect to another page like the below image show click on the SSH Client and copy the 3 and example command one by one as shown below image

chmod 400 ProjectX.pem

after that open terminal on path where you have downloaded the Key Pair ie; projectX.pem file and paste the command one by one to login to the server as like the below image shows and they will ask to add your system fingerprint please type yes and click on enter button to login the server

./automated_setup.shAll set we have successfully Setup and Logged in the EC2 Server, Next we have to Setup the SSH key to Git here am using GitHub if you do not want to configure the key you can skip the step and clone the project by Username and Password method refer the below tutorial to setup SSH-KEY to Github

after completing the ssh-key setup you have to clone the Master Script for the Automation and just run the script All Magic will happens..

https://github.com/Akshay-Krison/AutoDep-Laravel-ReDeploy

clone the above URL to you server like the below image shown

Next you have to Navigate to the directory and Just Run our 1st Command and click enter,

./automated_setup.sh

After that you can saw some questions will ask input the Details correctly as your project needs and Input Yes to start Auto deployment as below image shown

Here am Inputting the Server IP instead of domain (you can use your domain and the domain must be pointed to the IP) Wait until the Deployment complete…

Auto Deployment Start

Make sure you will get a success message Like the below image shows

After this just check the domain or The IP you have given in Browser to See the Application…!!!!!

Web Application Loaded

--

--