VOOZH about

URL: https://www.geeksforgeeks.org/linux-unix/how-to-set-up-apache-web-server-in-aws-ec2-linux-ubuntu-instance/

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


  • Courses
  • Tutorials
  • Interview Prep

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

Last Updated : 10 Apr, 2025

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.

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

Step 8: Sign in as Root User.

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

Step 17: Click Launch.

👁 Image

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’.

👁 Image

Step 19: Click ‘View Instances’.

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

Step 27: Click Install.

👁 Image

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

👁 Image

Step 29: Click File > Load private key.

👁 Image

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

👁 Image

Step 31: Click Ok.

👁 Image

Step 32: Click ‘Save private key’.

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

Step 37: Click Accept.

👁 Image

Step 38: Login as ‘ubuntu’.

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

Step 44: The Apache2 Ubuntu Default Page appears.

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image

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

👁 Image
Comment

Explore