Nginx, stylized as NGIИX, is a web server that can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache. The software was created by Igor Sysoev and publicly released in 2004. Nginx is free and open-source software, released under the terms of the 2-clause BSD license
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.
Install Nginx on centOS 8; Through this tutorial, we will learn how to install Nginx on CentOS 8.
How to Install Nginx on CentOS 8
Follow the following steps to install Nginx on CentOS 8:
- Step 1 – Install Nginx on CentOS
- Step 2 – Enable and Start Nginx
- Step 3 – Verify Status of Nginx
- Step 4 – Adjust Firewall
- Step 5 – Nginx Configuration File’s Structure
Step 1 – Install Nginx on CentOS
First of all, open terminal or command line and execute the following command into it to install Nginx on CentOS 8:
sudo yum install nginx
Step 2 – Enable and Start Nginx
Once the nginx installation is completed, then execute the following command on command line or terminal to enable and start nginx:
sudo systemctl enable nginx sudo systemctl start nginx
Step 3 – Verify Status of Nginx
Once the start and enable nginx, execute the following command on command line or terminal to verify status of nginx:
sudo systemctl status nginx
Step 4 – Adjust Firewall
Execute the following command on command line or terminal to adjust firewall settings:
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
Step 5 – Nginx Configuration File’s Structure
And use the following instrucations to configure file’s in nginx:
- All Nginx configuration files are located in the
- The main Nginx configuration file is
- Creating a separate configuration file for each domain makes the server easier to maintain.
- The Nginx server block files must end with
.confand be stored in
/etc/nginx/conf.ddirectory. You can have as many server blocks as you want.
- It is a good practice to follow a standard naming convention. For example, if the domain name is
mydomain.comthen the configuration file should be named
- If you use repeatable configuration segments in your domain server blocks, it is a good idea to refactor those segments into snippets.
- Nginx log files (
error.log) are located in the
/var/log/nginx/directory. It is recommended to have a different
errorlog files for each server block.
- You can set your domain document root directory to any location you want. The most common locations for webroot include:
Install Nginx on centOS 8; Through this tutorial, we have learned how to install Nginx on CentOS 8.