DEV Community

Cover image for Simple Ubuntu Nginx Web server setup on AWS
Bolaji A. Adetoye
Bolaji A. Adetoye

Posted on

Simple Ubuntu Nginx Web server setup on AWS

My humble beginning to becoming a DevOps Engineer through HNG 12 cohort internship.
The first task fondly called "stage0" came with setting up and configuring NGINX on a fresh Ubuntu server. This task will demonstrate the ability to work with basic web server configurations and deliver a functional web server, in this case, a static webpage.

Task Requirements:
NGINX Installation and Configuration
• Install the NGINX web server and ensure it is running.
• Configure NGINX to serve a custom HTML page as the default page (/var/www/html/index.html) with the message:
“Welcome to DevOps Stage 0 - [Your Name]/[SlackName]”
(Replace [Your Name] with the name and [SlackName] with your Slack Username).

  1. Spin Up an Ubuntu EC2 instance (free tier)
  2. Create an account on the Amazon Web Services platform (I will assume you have one already as this is beyond the scope of this blog).
  3. Search for EC2 in the services search box.

Image description

Image description
Click on the launch instance button.

Image description

  • Specify a suitable name for the server and select Ubuntu image icon from the list of the AMIs under Application and OS Images (Amazon Machine Image). Ensure that the AMI is free tier eligible to avoid unnecessary charges.

Image description

Keypair is not required as we would be using Amazon EC2 Connect to connect to the server. So select the "Proceed without a keypair" option from the drop-down list.

Image description

Ensure "Allow HTTP traffic from the internet" is checked as this would allow port 80 to access the static website. Leave other default settings as is and click "launch instance" at the right-hand side of the summary window.

Image description

Select the provisioned server and click the connect button at the top of the window to connect to the server. This would take us to the page below.

Image description
Click on Connect again.
This takes us to the Ubuntu terminal where Nginx server would be installed.

Image description
Run sudo apt-get update to update the current Ubuntu version packages.
sudo apt install nginx -y to install the Nginx. After the successful installation of the web server. We would need to configure our web server to serve a custom HTML page as the default page by navigating to the server page directory (/var/www/html).

Image description
Note that I encountered a "permission denied" error while trying to write to the directory. Ensure that you are in privileged mode to write to the directory. Start the Nginx server and enable the Nginx service which will persist and start the service automatically at boot times with the following commands.

systemctl start nginx
systemctl enable nginx
Enter fullscreen mode Exit fullscreen mode

Copy the Public IPv4 address of the server and paste it into a browser address bar.

Image description

We finally have our custom static web page as seen below.

Image description

References
• DevOps Engineers - https://hng.tech/hire/devops-engineers
• Cloud Engineers - https://hng.tech/hire/cloud-engineers

I hope you find this informative and I will see you in the next one.
Cheers!

Top comments (0)