How to Install Nginx on CentOS 7

Introduction

Nginx is a free, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. Nginx is written to address the C10K problem. Unlike traditional servers such as Apache, Nginx doesn't rely on threads to handle requests. Instead, it uses an event-driven (asynchronous) architecture.

In this tutorial, we will install Nginx on your CentOS 7 system.

Installing Nginx

First, we need to add CentOS EPEL package so we can install the latest version of Nginx.

# sudo yum install epel-release

Now we can use yum package manager to install the latest version Nginx.

# sudo yum install nginx

Nginx and other dependencies to run Nginx will install on your server. Press "y" when you are prompt to install Nginx.

Starting Nginx

Now we can start Nginx by using the following command:

# sudo service nginx start

And use the command below to make Nginx start on system boot:

# sudo systemctl enable nginx

Allowing HTTP and HTTPS traffic

If you have a firewall, we need to allow incoming HTTP and HTTPS traffic.