Nginx is a web server used to run web pages, similar to the Apache HTTP server with high performance. In this tutorial, I will show you how to install Nginx on CentOS!
First, because the CentOS default Repository does not contain Nginx’s installation package, you need to add a new repository named Extra Packages for Enterprise Linux (EPEL repository) to your operating system, by running the following command :
|
1 |
sudo yum install epel-release |

Enter Y to continue!
Result:

Now you can install Nginx.
Please run the following command!
|
1 |
sudo yum install nginx |

Enter Y to continue.
Installation successful:

Now, let’s start Nginx:
|
1 |
sudo systemctl start nginx |
To check the results, you can open your browser and request to the following address:
|
1 |
http://<domain_or_ip_server>/ |
If you see the browser displays the following, then you have successfully installed Nginx:

If you want Nginx to automatically start when we start the OS, let’s run the following command:
|
1 |
sudo systemctl enable nginx |
If your server is using a firewall, then enable allow for users to access the port of http and https:
|
1 |
sudo firewall-cmd --permanent --zone=public --add-service=http |
|
1 |
sudo firewall-cmd --permanent --zone=public --add-service=https |
Reload the firewall configuration:
|
1 |
sudo firewall-cmd --reload |
