Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to Set Up Apache Web Server in AWS EC2 Linux (Ubuntu) Instance?

  • Difficulty Level : Basic
  • Last Updated : 22 Nov, 2021

In this article, we will look into the process of setting up Apache Web Server in AWS EC2 Linux Instance.This tutorial has been done on a system running Windows 10 Home (Version 20H2).

Implementation:

The steps taken to complete this tutorial are being stated below:

Step 1: Go to portal.aws.amazon.com to create a new AWS account. Provide email address and password. Click Continue.

Step 2: Provide other details like Name, Phone Number, etc., and click Continue when done.

Step 3: Provide billing information and click ‘Verify and Continue’.

Step 4: Confirm your identity and click ‘Send SMS’. Confirm the OTP.

Step 5: Select a plan. Here, we choose ‘Basic support – Free’ and click on ‘Complete sign up’.

Step 6: AWS account has been successfully created. Click ‘Go to the AWS Management Console.

Step 7: Click on My Account > AWS Management Console.

Step 8: Sign in as Root User.

Step 9: Navigate to Services and select EC2 under Compute category.

Step 10: On the left pane, click on Instances under the Instances section. Click ‘Launch instances’.

Step 11: Now, we choose an Amazon Machine Image (AMI). Search for ‘ubuntu server 18.04 LTS’ and click Select.

Step 12:  Choose Instance Type. Here, we have chosen ‘t2.micro which’ is Free tier eligible. Click ‘Next: Configure Instance Details.

Step 13: Don’t change anything and click ‘Next: Add Storage.

Step 14: Set the size as 8 GiB and click ‘Next: Add Tags’.

Step 15: Click ‘Next: Configure Security Group’.

Step 16: Choose ‘Create a new security group’ and add SSH, HTTP, and HTTPS Types. Click ‘Review and Launch’ when done.

Step 17: Click Launch.

Step 18: Select ‘Create a new key pair’ and enter any key pair name in the given field. Leave the ‘Key pair type’ as RSA. Click ‘Download Key Pair’ to download the .pem file. Store it in a secure location as it will be used later. Click ‘Launch Instances’.

Step 19: Click ‘View Instances’.

Step 20: We can now see our instance named ‘inst1’ running.

Step 21: Go to putty.org to download PuTTY. Click on ‘here’.

Step 22: Under MSI (‘Windows Installer’) click the first link (next to 64-bit x86) to download PuTTY.  

Step 23: Go to puttygen.com to download PuTTYgen. Click on ‘PuTTY Installation Download page’.

Step 24: Under ‘puttygen.exe’ section click the ‘puttygen.exe’ link next to 64-bit to download it.

Step 25: Launch the setup to install PuTTY. Click Next.

Step 26: Specify the install location for PuTTY. Click Next.

Step 27: Click Install.

Step 28: After installing PuTTY, launch the PuTTYgen software. The following window appears.

Step 29: Click File > Load private key.

Step 30: Select the previously downloaded .pem file (ubuntuKey.pem) and click Open.

Step 31: Click Ok.

Step 32: Click ‘Save private key’.

Step 33: Enter a name for the generated .ppk file and click Save.

Step 34: Open PuTTY and enter the public IP of the instance in Host Name filed and keep Port as 22.

Step 35: Select Auth under SSH and click on Browse.

Step 36: Select the .ppk file (ubuntuppk.ppk) and click Open.

Step 37: Click Accept.

Step 38: Login as ‘ubuntu’.

Step 39: Ubuntu has started as we can see below.

Step 40: Update packages with the command ‘sudo apt-get update’.

Step 41: Install Apache2 using ‘sudo apt-get install apache2’.  

Step 42: Verify that Apache is running using the command ‘sudo systemctl status apache2’.

Step 43: Copy the public IP of the EC2 instance and paste it on a browser of the host OS.

Step 44: The Apache2 Ubuntu Default Page appears.

Step 45: cd into /var/www/html and open the index.html file in the nano editor.

Step 46: This is the default code. We need to replace this code with our own code for the sample webpage.

Step 47: The default code is replaced with our own code in index.html. Save and exit the editor.

Step 48: We can verify that we are able to access the hosted webpage using ‘curl’ inside the instance.

Step 49: The hosted web page can also be accessed from the host OS as shown.

Step 50: The hosted web page can also be accessed by another system (a smartphone – iOS 14.7.1) as shown.


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!