2018-09-23 · Tools

How to install Nginx on centos 7

NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. NGINX is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.

NGINX is one of a handful of servers written to address the C10K problem. Unlike traditional servers, NGINX doesn’t rely on threads to handle requests. Instead it uses a much more scalable event-driven (asynchronous) architecture. This architecture uses small, but more importantly, predictable amounts of memory under load. Even if you don’t expect to handle thousands of simultaneous requests, you can still benefit from NGINX’s high-performance and small memory footprint. NGINX scales in all directions: from the smallest VPS all the way up to large clusters of servers.


Step 1 – Configure Nginx repo for CentOS 7

To add NGINX yum repository, create a file named /etc/yum.repos.d/nginx.repo and paste one of the configurations below:


name=nginx repo


name=nginx repo

Due to differences between how CentOS, RHEL, and Scientific Linux populate the $releasever variable, it is necessary to manually replace $releasever with either 5 (for 5.x) or 6 (for 6.x), depending upon your OS version.

Step 2 – Install Nginx

sudo yum install nginx

Step 3 – Start/stop/restart nginx server

sudo systemctl enable nginx # run at server boot time

sudo systemctl start nginx # Start nginx command

sudo systemctl stop nginx # Stop nginx command

sudo systemctl restart nginx # Restart nginx command

sudo systemctl status nginx # Find status of nginx server command

Step 4 – Open port 80 and 443 using firewall-cmd

You must open and enable port 80 and 443 using the firewall-cmd command:

sudo firewall-cmd --permanent --zone=public --add-service=http

sudo firewall-cmd --permanent --zone=public --add-service=https

sudo firewall-cmd --reload

Open port on aliyun


Step 5 – Test it

Fire a web browser and type the ip address:



How to install and use Nginx on CentOS 7 / RHEL 7