How To Install Nginx on Linux

How To Install Nginx on Linux

How to Install Nginx on Linux

Hello dear,

In this guide, we'll walk you through installing Nginx on various Linux distributions, including Ubuntu, Debian, CentOS, and Fedora. The installation steps are similar, but there are some distribution-specific differences.

Ubuntu and Debian

Step 1: Update Package Lists

Before installing Nginx, it’s a good idea to update the package lists for the latest upgrades and new package installations. Open a terminal and run:

sudo apt update

Step 2: Install Nginx

To install Nginx on Ubuntu or Debian, run the following command:

sudo apt install nginx

This command will install the latest stable version of Nginx from the default package repository.

Step 3: Start Nginx

After the installation is complete, start the Nginx service and enable it to start automatically at boot with the following commands:

sudo systemctl start nginx sudo systemctl enable nginx

CentOS and Fedora

Step 1: Add the EPEL Repository (CentOS Only)

For CentOS users, you'll need to enable the EPEL (Extra Packages for Enterprise Linux) repository. This repository contains additional packages not available in the default CentOS repositories. Run the following command to enable EPEL:

sudo yum install epel-release

Step 2: Install Nginx

To install Nginx on CentOS or Fedora, run the following command:

sudo yum install nginx

This will install the latest stable version of Nginx from the repository.

Step 3: Start Nginx

After installation, start the Nginx service and enable it to start automatically at boot with these commands:

sudo systemctl start nginx sudo systemctl enable nginx

Step 4: Verify the Nginx Installation (All Distributions)

To check that Nginx is running, open a web browser and navigate to:

http://localhost

If you're accessing remotely, replace localhost With the IP address of your Linux machine. You should see the Nginx welcome page, which indicates that Nginx has been successfully installed and is running.

Summary

In this guide, we've covered the process of installing Nginx on various Linux distributions, including Ubuntu, Debian, CentOS, and Fedora. By following the steps outlined for your specific distribution, you should now have a working Nginx installation ready to handle web server and reverse proxy tasks.

Nginx offers excellent performance, scalability, and flexibility for web applications. As you continue using Nginx, you'll find many resources online to help you learn more and troubleshoot any issues you may encounter. The official Nginx documentation is an excellent starting point, along with community forums and blogs for additional support.

Souy Soeng

Souy Soeng

Our website teaches and reads PHP, Framework Laravel, and how to download Admin template sample source code free. Thank you for being so supportive!

Github

Post a Comment

CAN FEEDBACK
close