How To Install Nginx on CentOS 7

Published: December 1, 2025 (Updated: Dec 1, 2025)

Enjoying this content? Subscribe to the Channel!

Get Your Website Running: Installing Nginx on CentOS 7 (Step-by-Step Guide)


Hey everyone, Darren O’Neil here, and welcome back to Darren’s Tech Tutorials!

If you’re looking to deploy a fast, efficient, and robust web server on your CentOS 7 machine, you’ve come to the right place. Nginx (pronounced “Engine-X”) is a powerhouse, and in this comprehensive guide, we’re going to walk you through the entire installation process, ensuring your service is up, running, and ready to handle traffic immediately.

We’ll cover everything from adding the necessary repositories to starting the service and setting it up to automatically run when your server boots. Let’s dive in!


Prerequisites

Before we begin, ensure you have command-line access to your CentOS 7 server and have sudo privileges.

Step 1: Enabling the EPEL Repository

Nginx is not included in the default CentOS package repositories. To access the necessary installation files, we first need to install and enable the Extra Packages for Enterprise Linux (EPEL) repository.

Run the following command in your terminal:

sudo yum install epel-release

You should see output confirming that EPEL is already installed or is being installed successfully.

Step 2: Installing Nginx on CentOS 7

With EPEL enabled, installing Nginx is straightforward using the yum package manager.

Execute the installation command:

sudo yum install nginx

If prompted to accept the installation, type Y and hit Enter. The system will fetch all necessary dependencies and complete the Nginx installation.

Step 3: Managing the Nginx Service (Start and Enable)

Now that the files are on your system, we need to activate the web server.

3a. Start the Nginx Service

Use the service command to launch Nginx immediately:

sudo service nginx start

3b. Check the Service Status

It’s always a good practice to confirm that the service started successfully:

sudo service nginx status

You should see output indicating that Nginx is active and running!

3c. Ensure Nginx Starts on Boot

To prevent the server from going offline after a reboot, we need to configure Nginx to start automatically every time CentOS powers on. We use the chkconfig command for this:

sudo chkconfig nginx on

This step ensures that the Nginx service will be active immediately upon startup, giving you peace of mind.

Step 4: Verification: Checking That Nginx is Working

The best way to confirm a successful installation is to visit the web server itself.

On your CentOS machine (or remotely if networking is configured), open a browser (like Firefox) and navigate to localhost:

http://localhost

If everything is configured correctly, you will see the default welcome page, typically stating: “Welcome to Nginx on Fedora/CentOS”. This confirms that Nginx is running and serving files correctly!

Bonus Tip: Customizing the Default Web Page

The power of a web server comes from serving your custom content. By default, Nginx looks for files in a specific directory.

On CentOS 7, the default web directory (the document root) for Nginx is located here:

/usr/share/nginx/html/

To test this out, we can quickly replace the default index.html file with our own test page.

  1. Navigate to the HTML directory (optional, for reference):

    cd /usr/share/nginx/html/
    
  2. Create a simple test file (e.g., using vi or nano):

    sudo vi index.html
    
  3. Insert your custom content (e.g., “This is my Nginx test page”).

  4. Save and exit.

Now, if you refresh your browser at http://localhost, you should see your custom message displayed!


Conclusion

That’s it! In just a few simple steps, you have successfully installed and configured the powerful Nginx web server on your CentOS 7 system. You now have the foundation to host websites, set up reverse proxies, and handle high-traffic applications.

If this tutorial helped you get your Nginx server up and running, please give the video a Like—it really helps the channel! And for more clear, accessible tech tutorials, be sure to Subscribe to Darren’s Tech Tutorials.

If you ran into any snags during the installation, drop a comment below, and I’ll do my best to help you troubleshoot! Thanks for watching, and happy hosting!