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:
Step 2: Install Nginx
To install Nginx on Ubuntu or Debian, run the following command:
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:
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:
Step 2: Install Nginx
To install Nginx on CentOS or Fedora, run the following command:
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:
Step 4: Verify the Nginx Installation (All Distributions)
To check that Nginx is running, open a web browser and navigate to:
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.