How to Deploy a Server and Launch a Website using Amazon EC2

Oluwanifemi Loveth - Oct 18 - - Dev Community

In the first week of the AWS workshop, I learnt about AWS compute services. I learnt that whether I am building an enterprise, cloud-native or mobile apps, or running massive clusters to drive analysis workloads, it all starts with compute.
AWS computing services gives you right compute for your workload, offers built-in security, flexibility to optimize costs and provides compute resource where you need it.

Image description

Amazon EC2

In AWS cloud, amazon EC2 provides scalable computing capacity. It helps to develop and deploy applications faster, launch virtual servers, configure security and networking and to manage storage.

I tried my hands on the EC2 Linux hands on lab and I'll be showing you how I deployed a server and launched a website on Amazon EC2.

Getting started

I already have an AWS account, so I logged in, created an IAM user, and granted it an AdministratorAcess. Then, I logged in to the IAM user's account.

Step 1
I logged in into my AWS account, and confirmed that I was in the desired region. In this case, it was Europe (Stockholm) Region.
So I clicked on 'EC2', as seen below;
Image description

Step 2
Under Network and Security, I clicked on 'Key Pair', and then on 'Create Key Pair' in the top right corner as seen below;
Image description

Step 3
Then I typed in my key pair name, key type and file format which is .ppk as a windows user and clicked on 'Create key pair button' at the end.
The key pair was successfully created and the file was downloaded and saved to my local drive.
Image description
Image description

Step 4
To launch an Amazon Linux 2 instance and install a basic web page that will display information about my instance, I clicked on EC2 dashboard on the top left corner and then on launch instances.
Image description

Step 5
I filled in the details of my instance appropriately;
I put in the instance name:
Image description

Then for Amazon Machine Image, I selected Amazon 2023 Linux AMI
Image description

Then I selected 64-bit (x86) architecture and t3. Micro instance type
Image description

Then, for the key pair, I chose the key pair I created earlier. Under Network settings, I clicked on 'Edit' to set the space where EC2 will be located.
Image description

I edited the network settings as follows;
Image description

I checked default VPC and subnet. Auto-assign public IP was set to 'Enable'. Right below it, I clicked 'Create Security groups' to act as a network firewall.
Image description

Then I edited the security group rules as follows;
Image description

I also added a second security group rule for HTTP, TCP, *80, and set source type as ‘My IP’.
Image description

Under ‘Configure Storage’, I went with the default settings, and clicked on ‘Advance Details’.
Image description

I scrolled down to the bottom of the page, clicked the 'Meta Data version' dropdown and select V2 only (token required).
Image description

I entered this code (used in the hands on Lab I followed) in the User data field and selected Launch instance.
Image description

And my instance was launched successfully.
Image description

Step 6
I clicked the 'View Instances' button in the lower right hand portion of the screen to view the list of EC2 instances. Once your instance has launched, you will see your Web Server as well as the Availability Zone the instance is in, and the publicly routable DNS name.
Then, I clicked the checkbox next to your web server to view details about my EC2 instance.
Image description

Step 7
After my instance has passed the Status Checks. I opened a new browser tab and browsed the web server by entering the EC2 instance’s Public DNS name into the browser.
The EC2 instance’s Public DNS name can be found in the console by reviewing the Public IPv4 DNS name line highlighted above.
Image description

Hurray! I just deployed a server and launched a website in a matter of minutes.

Note that if you are using the Chrome web browser, when you paste the Public IPv4 DNS value to the web browser, if it does not run, https may be automatically added in front of the DNS value, so it may not run. Therefore, you should enter http://.

Cleaning Up

I had to clean up resources to avoid incurring costs.
I went ahead to delete the instance I created.
I selected the instance I created, and from the instance state menu, I selected 'Terminate Instance'
Image description

There was a pop up window, asking if I was sure I wished to terminate this instance. And since I was very sure, I clicked 'Terminate'.
And that was the end of the lab.

I hope this was helpful to you. Will you also try it out? Let me know your thoughts in the comment section.

. .
Terabox Video Player