DEV Community

Jesse Akowuah
Jesse Akowuah

Posted on

My First AWS EC2 Project: Hosting a Static Website

Are you looking to break into cloud computing? Let me share my recent experience setting up a static website on Amazon Web Services (AWS) using an EC2 instance. This project was a great introduction to cloud infrastructure and helped me gain hands-on experience with AWS.

Getting Started with EC2

First, I logged into the AWS console and searched for EC2. After navigating to the Instances section, I clicked "Create Instance." For this project, I chose a Linux server with a t3.micro instance type—perfect for learning as it's part of the AWS Free Tier.

Setting Up the Instance

Once my instance was running, I clicked on the instance ID to access its information page. The next step was connecting to the instance via SSH. I used Git Bash, ensuring I was in the same directory as my downloaded key pair (.pem) file.

To connect, I ran these commands:

chmod 400 keyparfilename.pem
ssh -i keyparfilename.pem ubuntu@ec2-public-IP-address.AWSareaID.compute.amazonaws.com
Enter fullscreen mode Exit fullscreen mode

Installing Necessary Software

After successfully connecting, I switched to root access with sudo su -. Then, I installed and started Nginx:

apt install nginx -y
systemctl start nginx
systemctl enable nginx
Enter fullscreen mode Exit fullscreen mode

I also installed unzip to help with unpacking the website files:

apt install unzip
Enter fullscreen mode Exit fullscreen mode

Deploying the Website

Next, I downloaded and unzipped the website files:

curl "name-of-zipped-file" -o "preferred-file-name.zip"
unzip preferred-file-name.zip
Enter fullscreen mode Exit fullscreen mode

Finally, I copied all the files to the Nginx web directory:

cp -r * /var/www/html/
Enter fullscreen mode Exit fullscreen mode

Viewing the Result

With everything set up, I copied the public IP address from the AWS console and pasted it into a web browser. Voila! My website was live.

Challenges and Learnings

While the process seems straightforward now, I encountered a few hiccups along the way. Understanding the EC2 dashboard took some time, and I initially struggled with SSH connections. However, careful reading of AWS documentation, Youtube videos, our slack channel and some troubleshooting helped me overcome these obstacles.

This project taught me valuable lessons about cloud infrastructure, Linux command line, and web servers. It's amazing to see how quickly you can deploy a website using cloud services!

If you're looking to start your cloud computing journey, I highly recommend trying out a similar project. It's a great way to get hands-on experience and build your confidence in working with AWS.

Image description
Screenshot of the Hosted Website
Website template accessed from : https://www.tooplate.com/view/2135-mini-finance

Top comments (0)