How to Install Nginx on CentOS 7

r00t April 9, 2018

Install Nginx on CentOS 7

In this tutorial we’ll learn how to install Nginx on CentOS 7. We will also install and configure its prerequisites. Nginx is one of the most common open source web server software. It is widely used for load balancing, reverse proxying, media streaming and much more. The specialization of Nginx is its capability to operate on little resource and handle a high number of requests. Nginx works as an internet server, proxy, load balancer and Reverse Proxy. Today Nginx is installed on more afterward 450 million servers net, and is used by a few of the maximum traffic sites on the internet such as Dropbox and Netflix.

I recommend to use a minimal CentOS server setup as a basis for the tutorial, that can be a virtual or a root server image with an CentOS 7 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

Install Nginx on CentOS 7

Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:

yum -y install epel-release
yum -y update

Step 2. Installing Nginx.

Install Nginx by running the following command:

sudo yum install nginx

Once the instillation is completed, you can make sure that Nginx service is running with the following command:

systemctl start nginx
systemctl enable nginx

Step 3. Configure firewall ports for Nginx.

Next, you will need to allow the default Nginx port 80 (HTTP) and 443 (HTTPS) using FirewallD. You can do this by running the following commands:

sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=443/tcp

Reload the firewall service for the changes to take effect:

sudo firewall-cmd –reload

Step 4. Test Nginx in your browser.

Now in your browser’s address bar, type the public IP address of Ubuntu 16.04 LTS server. You should see the “Welcome to nginx!” Web page which means Nginx Web server is running correctly.

Congratulation’s! You have successfully install Nginx on your CentOS 7 server. Thanks for using this tutorial for installing Nginx web server on CentOS 7 system.

The Tags:

Leave a Comment

Comments are closed.