Nginx is a free, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server. Nginx is written to address the C10K problem. Unlike traditional servers such as Apache, Nginx doesn't rely on threads to handle requests. Instead, it uses an event-driven (asynchronous) architecture.
In this tutorial, we will install Nginx on your CentOS 7 system.
First, we need to add CentOS EPEL package so we can install the latest version of Nginx.
# sudo yum install epel-release
Now we can use yum package manager to install the latest version Nginx.
# sudo yum install nginx
Nginx and other dependencies to run Nginx will install on your server. Press "y" when you are prompt to install Nginx.
Now we can start Nginx by using the following command:
# sudo service nginx start
And use the command below to make Nginx start on system boot:
# sudo systemctl enable nginx
If you have a firewall, we need to allow incoming HTTP and HTTPS traffic.
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
You can check if Nginx is installed by typing your IP address or domain name into your web browser.
If Nginx is installed correctly, you will see the Nginx default landing page, which should look like this:
By default Nginx HTML files will be located in /usr/share/nginx/html/.
Now you can add your HTML files to this directory and start using the web server.