Skip to main content

๐Ÿš€ Installing NGINX

NGINX is a high-performance web server and reverse proxy widely used for hosting websites and efficiently handling web traffic. This guide covers installation steps for Ubuntu, CentOS, and macOS.


โœ… Prerequisitesโ€‹

Before installing NGINX, ensure that:

  • You have root/sudo privileges on the server. ๐Ÿ”‘
  • Your system package manager is up to date. ๐Ÿ”„

๐Ÿ† 1. Installing NGINX on Ubuntu/Debianโ€‹

๐Ÿ›  Step 1: Update the System

sudo apt update && sudo apt upgrade -y

๐Ÿ“ฅ Step 2: Install NGINX

sudo apt install nginx -y

โ–ถ๏ธ Step 3: Start and Enable NGINX

sudo systemctl start nginx
sudo systemctl enable nginx

๐Ÿ” Step 4: Verify Installation

nginx -v

You can also check if NGINX is running:

systemctl status nginx

๐Ÿ† 2. Installing NGINX on CentOS/RHELโ€‹

๐Ÿ›  Step 1: Update the System

sudo yum update -y

๐Ÿ“ฅ Step 2: Install NGINX

sudo yum install epel-release -y
sudo yum install nginx -y

โ–ถ๏ธ Step 3: Start and Enable NGINX

sudo systemctl start nginx
sudo systemctl enable nginx

๐Ÿ” Step 4: Verify Installation

nginx -v

๐Ÿ† 3. Installing NGINX on macOS (Using Homebrew)โ€‹

๐Ÿบ Step 1: Install Homebrew (If Not Installed)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

๐Ÿ“ฅ Step 2: Install NGINX

brew install nginx

โ–ถ๏ธ Step 3: Start NGINX

brew services start nginx

๐Ÿ” Step 4: Verify Installation

nginx -v

๐Ÿ”ฅ 4. Allowing NGINX Through Firewall (If Enabled)โ€‹

๐Ÿ›ก Ubuntu/Debian (UFW Firewall)

sudo ufw allow 'Nginx Full'
sudo ufw enable

๐Ÿ›ก CentOS/RHEL (firewalld)

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload

๐Ÿงช 5. Testing NGINX Installationโ€‹

After installation, open your web browser and visit:

http://your-server-ip

You should see the default NGINX welcome page. ๐ŸŽ‰

To test via command line:

curl -I http://localhost

๐Ÿš€ Next Stepsโ€‹

Once NGINX is installed, proceed to:


๐ŸŽŠ Congratulations! You have successfully installed NGINX! ๐ŸŽŠ