DEV Community

Cover image for AWS EC2 + Nginx: Your First Web Server on Ubuntu
Okoye Genevieve
Okoye Genevieve

Posted on

AWS EC2 + Nginx: Your First Web Server on Ubuntu

The prerequisite of this section is to know how to comfortably launch an EC2 instance, but if you can't you can check out my previous posts which shows the steps on how to deploy an EC2 instance.

Setting Up Your AWS EC2 Web Server

Step 1: Connect to Your EC2 Instance

Navigate to your key file directory.
Connect using ssh -i "C:\Users<YourName>\Downloads\nginx-key.pem" ubuntu@.

Image description
Image description

Step 2: Update Packages & Install Nginx

Update your instance's package list: sudo apt update.
Install the Nginx web server: sudo apt install nginx.

Image description
Image description

Step 3: Start & Enable Nginx

Start the Nginx service: sudo systemctl start nginx.
Enable Nginx to start on boot: sudo systemctl enable nginx.
Check Nginx status: sudo systemctl status nginx.

Image description
.
Step 4: Verify Web Server Access

Copy your instance's Public IPv4 address from the AWS console.
Paste the IP into a web browser to see the Nginx welcome page.

Image description

Image description
.

Step 5: Edit Web Page Content

Open the default Nginx HTML file (e.g., /var/www/html/index.nginx-debian.html) using sudo nano.
To edit the file to display "Gene first time here":
Inside the nano editor, press Ctrl + A to select all existing code.
Press Delete, ctrl+k or Backspace to remove the selected HTML.
Save changes by pressing Ctrl + X, then Y, then Enter.
Finally, refresh your browser using the Public IP to see the updated page.

Image description
Image description
Image description
Image description

Congratulations! You've successfully deployed your very own Nginx web server on an AWS EC2 instance and even customized its content. This is a significant milestone in your cloud journey!

Remember, every great project starts with a single step, and you've just taken a powerful one into the world of cloud computing and web hosting. Don't stop here! Use this newfound knowledge as a springboard to explore more advanced configurations, delve into front-end development, or integrate other AWS services.

The cloud is vast, and your potential is limitless. Keep building, keep learning, and keep sharing your progress! Happy coding!

Top comments (1)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.