Introduction
NGINX (short for Engine X) is a free, open-source and powerful HTTP web server and reverse proxy with an event-driven (asynchronous) architecture. Nginx is a high performance web server software. It is a much more flexible and lightweight program than Apache HTTP Server.
It also works as a reverse proxy, standard mail and TCP/UDP proxy server, and can additionally be configured as a load balancer. This tutorial will teach you how to install and start Nginx on your CentOS 7 server.
Read Also: How to Install Apache on CentOS 7
Install Nginx on CentOS 7
1. First update the system software packages to the latest version.
[root@localhost ~]$ yum -y update
2. Add the CentOS 7 EPEL repository, use the following command:
[root@localhost ~]$ yum install epel-release
3. Next, Install Nginx
[root@localhost ~]$ yum install nginx
4. Start Nginx and enable it to start automatically at system boot.
[root@localhost ~]$ systemctl start nginx [root@localhost ~]$systemctl enable nginx
5. Configure firewalld to Allow Nginx Traffic
[root@localhost ~]$ firewall-cmd --zone=public --permanent --add-service=http [root@localhost ~]$ firewall-cmd --zone=public --permanent --add-service=https [root@localhost ~]$ firewall-cmd --reload
Test Nginx Server on CentOS 7
Now you can verify Nginx server by going to the following URL, a default nginx page will be shown.
http://SERVER_DOMAIN_NAME_OR_IP
Nginx Important Files and Directories
The default server root directory (top level directory containing configuration files): /etc/nginx.
The main Nginx configuration file: /etc/nginx/nginx.conf.
Server block (virtual hosts) configurations can be added in: /etc/nginx/conf.d.
The default server document root directory (contains web files): /usr/share/nginx/html.