Introduction

Amazon EC2 (Elastic Compute Cloud) allows you to run virtual machines in the cloud. In this article, we will launch an EC2 instance and set it up as a web server using Apache or Nginx. By the end, you will have a running web server that can serve web pages.

Step 1. Launch an EC2 Instance.

Step 2. Connect to the EC2 Instance.

Step 3. Install a Web Server Apache2.

Step 4. Test Your Web Server.

Step 5. Customize Your Web Page.

Since you are seeing the default Apache2 page, you can now replace it with your own custom webpage.

Navigate to the Web Root Directory

Run the following command in your terminal.

cd /var/www/html

Create a Simple HTML Page

Run this command to replace the default page with a new one.

echo '<h1>Welcome to My EC2 Web Server!</h1>' | sudo tee index.html

Root directory

Refresh the Browser

Go back to http://your-ec2-public-ip in your web browser.

You should now see

"Welcome to My EC2 Web Server!" instead of the default Apache page.

Another page

Conclusion

In this article, we successfully set up an Amazon EC2 instance as a web server using Apache2. By launching the EC2 instance, configuring the necessary security groups, installing Apache, and customizing the default web page, you now have a fully functional web server. You can use this setup to host static websites or further configure it for dynamic web applications.