# Day 26 : Configuring an EC2 Instance as a Web Server with Nginx

Welcome to Day 26. Today, we will learn how to configure an EC2 instance as a web server using Nginx. In this lab, you will discover what User Data Scripts are and how they work.

### What is User Data Script in AWS?

In AWS, **User Data** is a feature that allows you to automate the configuration of an Amazon EC2 instance when it is first launched. This process is commonly known as **bootstrapping**. Instead of manually logging into a server via SSH to install software or change settings, you provide a script (or other data) during the launch process, and AWS executes it for you.

### Common Use Cases

* **Software Installation**: Installing web servers (Nginx, Apache), databases, or runtime environments (Python, Node.js).
    
* **Updates**: Running `apt-get update` or `yum update` to ensure the OS has the latest security patches.
    
* **Configuration**: Setting environment variables, creating local users, or downloading application code from GitHub or S3.
    
* **Service Management**: Starting and enabling services so they survive a reboot.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766562689364/febeb911-9279-45e5-bb17-3db16507c11b.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766562739063/05af7381-e9bb-4bc5-9f8b-26d0c950a57f.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766562869643/8226adaa-ed85-41a2-a18c-5121ad48a92f.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766562918016/9486d6b8-c730-40d1-9663-d5cc4c85c9c8.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766562945273/7ebd43b7-ecee-4c18-8cb4-9b1011d3bde5.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766562761737/397fef78-29fc-4039-8139-2e34d0be1b18.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766562802498/0f2b39d9-4e19-4f54-ac2e-e6993b9ce9cc.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766563001978/c8f74903-35a8-48dd-85a2-48e00b7e213c.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766563096505/4d13d96c-5a33-462f-a7a8-12f96eb563e5.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766563131703/23536110-4ff6-4d24-b75c-62d1789f9858.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766563222290/982105ab-72e6-4f3a-b631-1b35b916af54.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766563678169/053f13fc-3b13-44e8-bb73-82b3b0e98940.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766563947593/d6f512f6-09c7-4353-b534-22b931f6ceee.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766563961529/c3413539-1830-4a03-b735-3994b5d0e52c.png align="center")

```bash
#!/bin/bash

sudo apt update -y

sudo apt upgrade -y

sudo apt install nginx -y

sudo systemctl start nginx

sudo systemctl enable nginx
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766563987893/28aeb22b-0fc6-4413-a015-2467ef59ed1b.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1766564002387/e511a38d-732d-4d31-b989-4348b119a4bf.png align="center")

Congratulations you did it. It looks good. This lab was successfully completed without any errors. See you in day 27. If you have any issues please let me know I will be happy to assist you. Stay tuned and learn together. If you find my article useful, please kindly like and share it.
