Launching and Configuring an EC2 Web Server on AWS

My AWS Article Collection: Exploring a Multitude of Topics

  1. Let's Talk about IAM Users in AWS
  2. Exploring AWS EC2 Instances: Features, Deployment, and Hands-On Insights (c-sharpcorner.com)
  3. From Novie to Pro: Navigating AWS EC2 Instances Hands-On

Objective

Within this article, we will delve into the process of launching a web server—an HTTP server—directly from our EC2 instance. Prior to initiating this process, ensure that you possess an active instance connect session. For reference, you can refer back to my earlier article, where this session setup was discussed.

Let's proceed with the task at hand and explore the steps required to launch and configure a web server on our EC2 instance.

To ensure a seamless instance connect session, please adhere to the following steps.

Step 1. Navigate to the Instance dashboard.

Step 2. Locate and click on the specific Instance ID. This action will direct you to the Instance summary page.

Step 3. Once on the summary page, access the "Connect" button positioned in the top right corner.

Step 4. Upon clicking, you will be redirected to the "Connect to instance" page.

Step 5. To finalize the connection process, simply click the "Connect" button situated at the bottom right corner.

I'd like to draw your attention to the fact that each of these steps has been meticulously detailed and accompanied by helpful screenshots in my preceding article. By following these instructions, you should have no difficulty in establishing the instance connect session.

If everyone could kindly confirm that the screen you are currently viewing aligns with the depiction I have provided, we can move forward with confidence. Hope you are all looking at the below screen, same as me.

Great! In order to proceed with the software installation on this instance, we need to assume superuser privileges. To accomplish this, the initial command to enter in the command prompt is as follows.

Sudo su Command

This makes us super users. We become the root, root has complete access to the entire EC2 instance.

This is precisely why we assume the role of the root user—to enable the installation of software without encountering any impediments.

ec2

You're right on track! Whenever we need to install software, we rely on a tool called a package manager. And guess what? One of the popular package managers already present on Linux 2 AMI is known as “YUM”.

If you just type YUM Command, we will see a number of options displayed on the screen as shown below.

ec3

Before installing any new software, we would make sure the existing software on it is updated.

To verify this, we need to run the command "yum update -y" as demonstrated below. This command ensures that all the currently installed packages are brought up to date.

helpers

The next command I would want to run is yum install httpd. This httpd launches an Apache web server.

processing

In the above screen, it’s saying this is the package. This is the download size. Is that Okay? So make sure you enter Y (yes).

Hence with this, we successfully installed httpd on our EC2 Instance.

Usually, what do we do after installing any software? We want it to start up and running, isn’t it?

How can we start httpd up?

There is a command to do so. It’s systemctl start httpd.

There's one more step we need to take. We want to ensure that "httpd" starts automatically whenever the server restarts.

There is a command to do so. It’s systemctl enable httpd.

Now let’s see what would happen if I launch the webserver up.

How can I launch the webserver up?

Go to the Instances page and click on instance id.

Scroll down and locate the "Security Groups" option in the "Security" tab, as demonstrated below.

ec2 expereinece

This security group was created for us when we created the EC2 instance, proceed to click on security group, and if you scroll down, you can see that the security group has inbound rules and outbound rules.

launchwizard

If you look at the default security group, which was created, allows SSH Connection. If you remember earlier, we made an SSH connection to this specific machine to the EC2 instance, and that is allowed because the default security group allows SSH Connection.

If this EC2 instance, we have to enable HTTP connections. To do so, click on edit inbound rules and add a new rule, as shown below.

edit rules

Requests which are coming into this instance are called Inbound rules. Only SSH and HTTP are allowed now.

However, outbound, we are allowing everything from the EC2 instance. You can make a request for anything.

Find out the public IP address and paste it into the browser, as shown below.

instancesummary

You will see the below template in the browser.

testPage

Conclusion

We have successfully launched an EC2 instance and taken the initial steps of setting it up. After the launch, we efficiently installed essential software using a minimal set of commands, streamlining the process. To enhance accessibility, we then expanded the capabilities of the instance by adding HTTP to its security group. This step enables us to access HTTP sites seamlessly.

As a result of our efforts, I'm pleased to share that the EC2 instance is now up and running flawlessly, marking a significant achievement in our project. Isn’t this Awesome?

Did you find the article helpful and enjoyable?


Similar Articles