Published February 28, 2018 by

Install Nginx on CentOS/RedHat 7

Nginx is a high-performance web server software. It is a much more flexible and lightweight program than Apache Web Server.

It also works as a reverse proxy, standard mail, and TCP/UDP proxy server, and can additionally be configured as a load balancer. It is powering many sites on the web; well known for its high-performance, stability and feature-rich set.

In This tutorial, I will explain to you how to install and start Nginx on your CentOS 7 server.

Few things that you need to keep in mind about Nginx
  • Nginx installed in /etc/nginx.
  • Nginx Configuration file under /etc/nginx/nginx.conf.
  • Nginx virtual hosts configurations file under /etc/nginx/conf.d.
  • The default server document root directory (contains web files) in /usr/share/nginx/html.
      First, update server system

      # sudo yum update -y

      Add the CentOS 7 EPEL repository (For CentOS Only)

      # sudo yum install epel-release

      Add Redhat Nginx repository (For Redhat Only)

      rpm -Uvh

      Install Nginx

      # sudo yum install nginx

      Start Nginx

      # sudo systemctl start nginx
      # sudo systemctl enable nginx
      # sudo systemctl status nginx

      Setting firewall for run HTTP and HTTPS traffic

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

      Now Go to Browser and hit http://server_domain_name_or_IP/

      If you show this screen, that means you are successfully installed and configures Nginx.