🆖How To Install Nginx Website on CentOS 7

Introduction

NginX

NGINX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. It started out as a web server designed for maximum performance and stability. In addition to its HTTP server capabilities, NGINX can also function as a proxy server for email (IMAP, POP3, and SMTP) and a reverse proxy and load balancer for HTTP, TCP, and UDP servers.

NGINX as a Web Server

The goal behind NGINX was to create the fastest web server around, and maintaining that excellence is still a central goal of the project. NGINX consistently beats Apache and other servers in benchmarks measuring web server performance. Since the original release of NGINX, however, websites have expanded from simple HTML pages to dynamic, multifaceted content. NGINX has grown along with it and now supports all the components of the modern Web, including WebSocket, HTTP/2, gRPC, and streaming of multiple video formats (HDS, HLS, RTMP, and others).


Configuration

Adding the EPEL Software Repository

To add the CentOS 7 EPEL repository, first connect to your CentOS 7 machine via SSH, then use the yum command to install the extended package repository:

sudo yum install epel-release -y

Next, you’ll install the actual nginx software package.

Installing NginX

Now that the EPEL repository is installed on your server, install Nginx using the following yum command:

sudo yum install nginx -y

Enable NginX Service

sudo systemctl enable nginx
sudo systemctl start nginx

Add NginX service to Firewalld

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

Add Website From Github

Install git

sudo yum install git -y

Delete NginX Default Website Display

The default server root directory is /usr/share/nginx/html/. Files that are placed in there will be served on your web server. This location is specified in the default server block configuration file that ships with Nginx, which is located at /etc/nginx/conf.d/default.conf.

sudo rm -rf /usr/share/nginx/html/*

Add Website From Github

sudo git clone https://github.com/ryzwan29/portfolio.git /usr/share/nginx/html/

Restart NginX Services

sudo systemctl restart nginx

Last updated