🌐Install NginX in EC2 Instance

Introduction

What is NginX

NGINX is open-source web server software that functions as a reverse proxy, HTTP load balancer, and email proxy for IMAP, POP3, and SMTP. NginX is also one of the most popular and reliable web servers. This is an excellent choice if we want to host a website on AWS EC2. AWS EC2 (Elastic Compute Cloud) is a cloud computing service that allows us to rent virtual servers and manage them in the AWS cloud.


Configuration AWS

Create a New EC2 Instance

Name : Nginx-Rizwan
OS : Ubuntu 22.04
Instance Type : t2.micro
KeyPair: Vockey (.pem)
Security Group : Open SSH, HTTP, and HTTPS
Storage : 10GB

Configuration EC2 Instance

Update Repository

sudo -i
apt update && apt upgrade -y

Install Package

apt install nginx php-fpm -y

Add php info File

nano /var/www/html/info.php
<?php
phpinfo();
?>

Change File Default NginX

nano /etc/nginx/sites-available/default
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html index.php;   

# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
        include snippets/fastcgi-php.conf;

        # With php-fpm (or other unix sockets):
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
        # With php-cgi (or other tcp sockets):
        #fastcgi_pass 127.0.0.1:9000;
}

Last updated