After years of interest in cloud computing—soaking up some theoretical knowledge and understanding some core concepts, (shared my interest & journey on LinkedIn)—
I finally dived into hands-on, on AWS EC2, and I must say—it was both exciting and a little nerve-wracking at first. 😅 But after going through the process, I feel more confident in working with cloud services. So, I’m sharing my step-by-step experience of configuring an EC2 instance and deploying a simple website.
If you’re just starting with AWS, I hope this helps you get up and running faster! 🚀
Step 1: Launching an EC2 Instance: Amazon EC2 (Elastic Compute Cloud) provides virtual servers to run applications. My first task was to set up an instance where my website would be hosted.
Creating an EC2 Instance
- I logged into my AWS Management Console.
- I Navigated to the EC2 Dashboard and clicked Launch Instance.
- Configured the instance with:
- Amazon Machine Image (AMI): I chose Amazon Linux 2 (Free Tier).
- Instance Type: t2.micro (also Free Tier-friendly).
- Key Pair: Created a new key pair for secure SSH access.
- Security Group: Allowed SSH (port 22) and HTTP (port 80).
Clicked Launch and my instance was up in a few seconds!
Step 2: Connecting to the EC2 Instance via SSH
Once the instance was running, I needed to access it remotely from my terminal.
On my local machine, I ran:
ssh -i my-key.pem ec2-user@my-instance-ip
And boom! I was inside my EC2 instance.
Step 3: Installing a Web Server (Apache)
To serve a website, I installed Apache (HTTPD) on my instance using the following commands:
sudo yum update -y
sudo yum install -y httpd
sudo systemctl start httpd
sudo systemctl enable httpd
It is best practice to always update your server before installing any software. In this case:
• Apache (or Nginx) is the web server responsible for serving your website.
• yum is the package management system used on Amazon Linux.
• sudo yum update ensures that all installed packages are up to date before proceeding with new installations.
By running these commands, I successfully set up Apache to start automatically whenever the server reboots.
To confirm it was running, I visited my public IP in a browser and saw the default Apache page.
Step 4: Uploading My Website Files
To test my web server, I created a simple index.html file inside Apache’s root directory:
echo "<h1>Hello from my first AWS-hosted website!</h1>" | sudo tee /var/www/html/index.html
After running this command, I refreshed my browser, and my website was live!
Breaking Down the Command
echo "<h1>Hello from my first AWS-hosted website!</h1>" | sudo tee /var/www/html/index.html
This command creates a simple HTML file (index.html) inside the Apache root directory (/var/www/html/) and writes a message inside it. Let’s break it down step by step:
- echo "
Hello from my first AWS-hosted website!
" • The echo command prints text to the terminal. • Here, it’s printing the HTML content:
Hello from my first AWS-hosted website!
| (Pipe Operator)
• The pipe (|) takes the output of one command (echo) and passes it as input to another command (tee).sudo tee /var/www/html/index.html
• tee takes input from echo and writes it to the file (index.html).
• sudo ensures that tee has the necessary permissions to write to /var/www/html/, which requires root access.
Final Outcome:
• A new file index.html is created (or overwritten) inside /var/www/html/.
• The file contains:
Hello from my first AWS-hosted website!
This becomes the homepage of your website when accessed via a browser.
Using EC2 for computing is extremely flexible, cost-effective, and fast compared to running your servers on-premises.
Next, I’ll be exploring:
The same topic with practical pictorials or videos.
Automating deployments with Bash scripts
Connect With Me
GitHub: https://github.com/Glory-cloud-solution
LinkedIn: https://www.linkedin.com/in/glory-ugochukwu-
💬 I’m actively learning and growing my expertise in cloud architecture, Terraform, Linux, and automation scripting to enhance cloud-based solutions and share insights on AWS hands-on labs. If you’re learning AWS too, or you are a professional, let’s connect! Share your questions or tips in the comments. Let’s grow together!
Top comments (0)