Deploying Your HTML Website to an Amazon EC2 Instance
Tags: ec2, html, deployment, cloudskills
Published: 2023-05-25 17:35:47

Hello everyone, and welcome to my blog! In today's article, we will explore how to deploy your HTML website to an Amazon EC2 instance and ensure it is working correctly. If you find the content useful, please consider liking, sharing, and subscribing to my blog. So let's dive right in!

##Prerequisites:
Before we proceed, make sure you have the following:

An Amazon Web Services (AWS) account: If you don't have one, you can sign up here: https://aws.amazon.com.
Once your account is set up, you're ready to go!


##Deploying an EC2 Instance:
Follow these steps to deploy an EC2 instance:

Log in to your AWS account and access the AWS Management Console.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zhu8cqlx88x18d232318.png)

Locate the EC2 (Elastic Compute Cloud) service. If you can't find it, you can search for "EC2" in the search bar.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j915jyd3chapz7zs7z1l.png)

Click on "EC2 instances" to view your instances. If you don't have any instances yet, don't worry, we'll create one now.
Click on "Launch Instance" to start the instance creation process.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cqv1jh1q7zwjgc5jj8zk.png)
Give your instance a name, such as "My Instance for my blog."
Choose the operating system (OS) for your instance. You can select from various options like Amazon Linux, Ubuntu, or Windows, I selected Amazon Linux .
Select the one that suits your requirements.
Choose the instance type based on the required resources.
Configure additional settings like storage, security groups, and network settings. For now, we'll keep the default configurations.
Create or select an existing key pair to securely access your instance, i created a new key pair.
Review your settings and click "Launch Instance."

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ytu4gh9dkja58enzzsod.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kfjht8xuao1w5y0gxt98.png)



##Installing and Configuring the Web Server:
Once your EC2 instance is launched, follow these steps to install and configure the web server:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o5v3wb8lf1k7af0u3n8v.png)

Connect to your EC2 instance using EC2 instance connect or SSH.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8yrnaoyiezdpd1cakm93.png)

Update the system by running the command: sudo yum update -y.
Install the Apache HTTP Server (httpd) by running the command: sudo yum install -y httpd.
Start the Apache server by running the command: sudo service httpd start.
Check the status of the server by running the command: sudo service httpd status. It should show "active."
Create a directory to store your website files by running the command: mkdir /var/www/html.
Move your website files to the appropriate folder by running the command: sudo mv /path/to/your/files/* /var/www/html/.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvl36tu7rziqq4e7kvlz.png)

Go to security groups and edit inbound rules, add HTTP and HTTPS to allow anywhere and save, this allows you to define the permissions for incoming connections based on the source IP addresses, protocols, and ports.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bx095k4qxe6e3v5ugwq6.png)

##Checking Your Deployed Website:

To ensure your website is deployed correctly, follow these steps:

Copy the public IP address of your EC2 instance.
Open a web browser and paste the IP address in the address bar.
If everything is set up correctly, you should see your website displayed in the browser.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3i9t1sb75e7ub6uldjbp.png)

Conclusion:
Congratulations! You have successfully deployed your HTML website to an Amazon EC2 instance. By following the steps outlined in this article, you can easily host your website and make it accessible to the world. If you have any questions or face any issues during the deployment process, feel free to leave a comment below. Thank you for reading, and happy website deployment!