Hosting a Web Server on AWS EC2 Instance

Web Server on AWS EC2 Instance

In this post we are going to learn about how to turn an EC2 instance into a Web Server. For steps on how to bring up an AWS EC2 instance refer to <Post Launching EC2 Instance>.

Advertisements

As we see below, we already have an EC2 instance up and running. The details of the instance are as below:

  • AMI: Linux AMI 2
  • Type: t2 micro
  • VPC:  Default

Related – Default VPC vs Custom VPC in AWS

Security GroupWeb DMZ which allows SSH on port 22 and HTTP on port 80. HTTP needs to be allowed specifically in security group so we have access the Webserver hosted on the EC2 instance.

Related – AWS EC2 Instance Pricing Model

You can connect to your EC2 instance by clicking on Connect & you shall be able to SSH to the EC2 Instance.

You will get 3 options to SSH into EC2 Instance.

We select EC2 Instance Connect to used browser based SSH connection.

Now once you are at the shell of EC2 instance, here are the steps you need to follow to turn your EC2 instance to a Web Server.

Step 1: Switch to root ‘sudo –I’ & Look for any OS updates required, run ‘yum update -y’

Step 2: Install the Apache to turn your EC2 to Web Server. Run ‘yum install httpd -y’

Step 3: Check now the /var/www/html directory exists and anything we put under this directory would be accessible from the http on port 80.

Step 4: Let’s create a very basic html file that we will access from web.

Type ‘nano index.html’ to create a new file under www directory

Click Ctrl + X and save the index.html file.

Next verify the file is saved under the var/www/html/ directory.

Step 5: Start the httpd service and verify the same

Step 6: Go to the browser and input your EC2 instance IP address and you shall be able to see the below output.

 

Share this:
Advertisements

Tags:

Related Posts

About The Author

Add Comment

Social Media Auto Publish Powered By : XYZScripts.com
Select your currency
USD United States (US) dollar