Deploying Web Servers with AWS EC2: A Step-by-Step Guide for beginners

Deploying Web Servers with AWS EC2: 
A Step-by-Step Guide for beginners

In today's digital age, businesses are increasingly relying on cloud services to power their applications, websites, and more. Amazon Web Services (AWS) is a frontrunner in the cloud computing space, offering a plethora of services and features to cater to various needs. If you're looking to launch a new web-based application, AWS Virtual Machines (EC2), provides a flexible and scalable platform to get you started.

In this blog post, we'll embark on a journey through AWS, specifically the US East (N. Virginia) region, and explore how to configure resources to create web servers. Our goal is to set up an Ubuntu-based virtual machine and install the popular Nginx web server, culminating in a simple yet powerful "Hello World" web page. So, whether you're a seasoned cloud architect or a curious beginner, let's dive into the world of AWS and take your first steps towards web hosting mastery.

Before we delve into the steps, let's gain a better understanding of why this journey is important. AWS not only simplifies the process but also opens doors to an array of features that can enhance your web applications' performance, security, and scalability.

So, without further ado, let's roll up our sleeves and embark on this exciting adventure in AWS, where we'll transform a basic instance into a powerful web server capable of serving content to the world.

Step 1: Creating an AWS Instance in us-east-1 with an Ubuntu OS

  1. Sign in to AWS Console: To begin, you need to sign in to your AWS account. If you don't have an account, you can create one on the AWS website.

  2. Navigate to EC2.

  3. To set up your virtual machine in the US-east-1 region, ensure that you have selected it from the AWS Management Console. This region is popular for its excellent availability and performance.

  4. On the left-hand side, you'll find the "Instances" option. Click on it to access the instances management panel.

    Once you're on the Instances page, look for the "Launch Instances" button. It's typically located at the top or prominently displayed on the page. Click on this button to initiate the instance creation process.

  5. Enter a descriptive name for your instance in the provided text field. This name will help you identify and manage your instances easily, especially when dealing with multiple instances. Make sure to choose a name that reflects the purpose or role of this instance, such as "WebServer" or "DevelopmentInstance."

  6. Choose an Ubuntu AMI for your virtual machine. You can search for "Ubuntu" in the AMI search bar.

  1. Select an appropriate instance type based on your requirements. For a basic web server, a t2.micro instance is usually sufficient.

  1. Select the key pair.

  1. Create a new one if no key pair is created for the current region.

Click on Create key pair and download the .pem file We’ll use PuTTY to create a .ppk file to access the EC2 instance.

  1. In the network settings, select the check boxes corresponding to SSH and HTTP Traffic.

  1. Configure the amount of storage you want for your instance. The default 8 GB of gp2 volume should be enough for a basic web server.

  1. Review the summary of the EC2 instance and click on the Launch Instance. It’ll take a moment to initiate the instance.

  1. A newly created instance is launched in the availability zone in the US-East-1 Region.

  1. We’ll now open PuTTY & copy this Public IP to access the instance from PuTTY.

  1. Open PuTTY & paste the copied Public IP in the Host Name (or IP address).

  1. Then go to, Connection -> SSH -> Auth -> Credentials.

Now we need a putty private key file for authentication to access the instance. So we’ll now open PuTTYgen & generate the .ppk file from the .pem file.

Generating .ppk from .pem:

  1. Select the generated .ppk file and then click on Open

  1. It is successfully connected to the instance. Click on Accept.

  1. Enter ubuntu as username to log in to the instance.

Now our Ubuntu instance is ready for use.


Step 2: Setting up the Nginx Web Server

  1. Now we’ll install NGINX for XYZ corporation to make web servers.

    Before installing nginx, we’ll first update the system packages using the command:

    sudo apt-get update

    • This command is used to resynchronize the package index files from their sources.

    • The indexes of available packages are fetched from the location(s) specified in /etc/apt/sources.list.

    • This command retrieves and scans the files, so that information about new and updated packages is available

  2. Installing NGINX using the command sudo apt-get install nginx -y

    Now the nginx web server is successfully installed and is ready to be accessible from the internet. We can verify this by entering the public IP of this instance in the web browser.

    We can see that the default webpage of the nginx server is accessed successfully.


Step 3: Customizing the Default Website

  1. Our next task is to Change the default website with a page displaying the message: “Hello World”.

    For this, We’ll now change our directory to /var/www/html where the default webpage exists. Use the cd /var/www/html/ command for this

    We can see the file index.nginx-debain.html

  2. We’ll now open the vi editor to modify this webpage to display the message Hello World using the command: sudo vi index.nginx-debain.html

  3. We’ll remove all paragraphs (<p>) except the last one. And we’ll change the text of <title> and <h1> to Hello World!

All paragraphs (<p>) except the last one are removed and the text of <title> and <h1> is changed to Hello World!

You should see the "Hello World!" message displayed on the web page.


In this blog post, we've demonstrated how to create an AWS Virtual Machine in the US-east-1 region, install Nginx, and set up a basic "Hello World" web page. This is just the beginning of your AWS journey; from here, you can expand your web server capabilities, configure domain names, and scale your infrastructure as needed.

AWS offers a wide range of services and features to cater to various use cases. Whether you're hosting a personal blog or running a complex e-commerce website, AWS has you covered. Keep exploring and learning to make the most of AWS's cloud computing capabilities and enhance your online presence. Happy web serving!


Did you find this article valuable?

Support SIDDHANI VAMSI SAI KUMAR by becoming a sponsor. Any amount is appreciated!