Web server configuration is a fundamental aspect of DevOps engineering. This article presents a case study of NGINX deployment on a freshly provisioned Ubuntu server on Amazon Web Services, as undertaken for the HNG DevOps Stage 0 challenge. The subsequent section details the methodology employed and highlights the key takeaways from this technical exercise.
Technical Requirements
To successfully set up and configure NGINX on a fresh Ubuntu server hosted on AWS, ensure you have the following tools:
1. AWS Account: To provision and manage EC2 instances.
2. SSH Client: For secure remote access to your Ubuntu server.
3. Ubuntu Server on AWS EC2: The virtual machine where NGINX will be installed.
4. NGINX: The web server software to be installed.
5. Text Editor:For editing configuration files and creating custom HTML pages.
6. Web Browser:To test and verify the web server's functionality.
Steps
Step 1: Setting Up an Ubuntu Server on AWS
- Log in to the AWS Management Console.
- Navigate to EC2 and create a new instance.
- Select Ubuntu 22.04 LTS as the operating system.
- Chose an instance type (free-tier eligibility works fine).
- Configure security groups to allow:
- SSH access (port 22)
- HTTP traffic (port 80)
- Downloaded the private key (.pem) file to securely connect to the instance.
ssh -i /path/to/key.pem ubuntu@your-server-ip
Step 2: Install NGINX
- Once connection to the server is Establish, proceed with installing NGINX:
sudo apt update && sudo apt upgrade -y
sudo apt install nginx -y
- After installation, start and enable NGINX:
sudo systemctl start nginx
sudo systemctl enable nginx
- To verify that NGINX is running, use:
sudo systemctl status nginx
- Open a browser and navigate to http://your-server-ip this displays the default NGINX welcome page, confirming a successful installation.
Step 3: Configuring NGINX to Serve a Custom Page
- To personalize the default page, edit the index.html file:
sudo nano /var/www/html/index.html
- replace the existing content with the following HTML code:
<html>
<head>
<title>Welcome</title>
</head>
<body>
<h1>Welcome to DevOps Stage 0 - [Your Name]/[Your Slack Name]</h1>
</body>
</html>
- After saving the file then restart the NGINX service to apply the changes:
sudo systemctl restart nginx
- Finally, verify that the custom welcome message is displayed by visiting http://your-server-ip in a web browser.
Key Takeaways
Here are the top things to take away from this project:
- Provisioning an AWS EC2 instance: how to create a virtual server on Amazon Web Services (AWS) using EC2. This is a fundamental skill for anyone working in cloud computing.
- Linux command-line operations: The use of Linux commands to navigate, install software, and configure the server. This is an essential skill for any developer or system administrator.
- Installing and configuring a web server: how to install and set up a web server using NGINX. This involved configuring files, restarting the server, and testing everything to making sure it works.
- Troubleshooting common server issues: As I worked on this project, I encountered some errors and issues. I learned how to troubleshoot these problems using online resources, documentation, and good old-fashioned debugging techniques.
These skills are crucial for anyone working in DevOps, cloud computing, or web development.
For Professional Service
Cloud Engineers
Platform Engineers
Top comments (0)