Hi!.
In today's article, I will be walking through the steps to install and configure Nginx on Amazon EC2 using the Ubuntu Server. This is the first task of my HNG DevOps Internship and I am to serve a custom HTML page that shows my name and Slack username.
Setting Up Ubuntu On Amazon EC2.
- The first step is to create an EC2 instance using the Ubuntu AMI.
- Instance Type: An instance type specifies the hardware to be used for the instance. I used the t2 micro instance type since it is free tier eligible.
- Security Group: A security group is a set of firewall rules that control the traffic for my instance.
- Key Pair: To securely connect to my instance.
After creating The EC2 Instance and it is up and running, I am able connect to the EC2 Instance and start the Nginx installation process.
To install Nginx, I used these commands:
sudo apt update
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
After enabling nginx, I added my name and Slack username to the HTML file using the vi editor.
sudo vi /var/www/html/index.html
After saving the HTML file, I had to reboot Nginx so that I could get the new changes with these commands:
sudo systemctl restart nginx
sudo systemctl status nginx
To verify that the custom HTML Page has been rendered on my browser, I navigated to the IPv4 address generated by AWS for the instance in my web browser.
Challenges
I was opening the IP address link directly from AWS and by default it was an HTTPS address and I kept having the "CONNECTION_REFUSED" error on my browser. I later discovered that Nginx default config is HTTP only and i had to force my browser to use HTTP.
How this task contributes to my learning and professional goals.
Working on this task has helped me enhance my troubleshooting skills. in a bid to understand the issue with the connection refused error on my browser, I was able to learn more about networking.
Devops Engineers
Cloud Engineers
Author Of article : Success John Read full article