Install NGINX on Centos 7

In this article, we want to teach you what Nginx is and show you How to install Nginx on Centos 7. Before we go to install Nginx, let’s see what Nginx is and how it works.

What is Nginx?

Nginx is open-source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. It started out as a web server designed for maximum performance and stability. In addition to its HTTP server capabilities, Nginx can also function as a proxy server for email (IMAP, POP3, and SMTP) and a reverse proxy and load balancer for HTTP, TCP, and UDP servers. And it is more flexible than the Apache HTTP server.

Steps To Install NGINX on Centos 7

To install Nginx on Centos 7, It’s better to log in as a non-root user with root privileges. To do this, you can check this on the Initial server setup with the Centos 7 article.

Now follow the steps below to complete this guide.

Step 1 – Add Epel Repository repository on Centos 7

First, run the system update with the command below:

sudo yum update -y

For installing Nginx you should add the Centos 7 EPEL repositories first with the following command:

sudo yum install epel-release -y

Step 2 – Command To Install Nginx on Centos 7

Now you can install Nginx with the following command:

sudo yum install nginx 

Answer yes to install. Then, start Nginx on Centos 7 with the following command:

sudo systemctl start nginx

Also, you can enable your service to start on boot with the command below:

sudo systemctl enable nginx

Step 3 – Configure Firewall for Nginx on Centos 7

If you are running a firewall you should allow HTTP and HTTPS traffic with the following commands:

# sudo firewall-cmd --permanent --zone=public --add-service=http 
# sudo firewall-cmd --permanent --zone=public --add-service=https
# sudo firewall-cmd –reload

Note: If you haven’t firewalld first install it then run the commands above.

sudo yum install firewalld

Start and enable firewalld with the following command:

# sudo systemctl start firewalld
# sudo systemctl enable firewalld

Don’t forget to run the commands above after the firewalld installation.

Step 4 – Verify Nginx Web Server Installation

At this point, you need your server’s IP address. You can find your public IP address by running the command below:

ip addr

In your output, the eth0 interface is what we want. Run the following command to get your IP address:

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

Now you can test by visiting your server’s public IP address in your web browser.


Here you will see the default CentOS 7 Nginx web page in your web browser. If you see the page your web browser is correctly installed and working.


At this point, you have learned what Nginx is and how it works and you can easily use Linux commands to install it on your Centos 7 server.

Hope you enjoy it. Stay with us for more articles.

Also, you may like these articles:

Fix Nginx Error 404 Not Found

Configure Nginx as a load balancer

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!