Install Nginx on CentOS/Host website on Nginx.

In this POST we will look, how we can install Nginx on CentOS and host one small website on Nginx.

Nginx is an open-source application which is used as web serving, reverse proxy, load balancing, media streaming and many more.

Nginx is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption.

Source code of Nginx is in C language and works on port 80. You can visit the official website.

QUICK view to installing Nginx on CentOS
STEP 1: Install epel-release package using yum command.
# yum install epel-release
STEP 2: Install Nginx package using apt command.
# yum install nginx

# systemctl status nginx
**To check the status of Nginx service**

# systemctl start nginx
**To start the Nginx service**

# systemctl stop nginx
**To stop the Nginx service**

# systemctl reload nginx
**To reload the Nginx service**

# systemctl restart nginx
**To restart the Nginx service**
STEP 3: Check the IP and put that into the browser to get the Nginx Page.
# ifconfig
STEP 4: Host our own website in Nginx.
Go to the "/usr/share/nginx/html" and make index.html and write the basic code.

Just refresh the page on the browser you will see your new page.

After the Quick view please read the POST to get the detailed Knowledge about the hosting in Nginx.

Install and configure Nginx on CentOS.

STEP 1: Install epel-release package using yum command.

# yum install epel-release

So, we had to install Extra Packages for Enterprise Linux(EPEL) with the help of above command now we will install Nginx package.

STEP 2: Install Nginx package using yum command.

# yum install nginx

This will install the Nginx package and then we check the status by using below command.

# systemctl status nginx

If you want to start the service then use start in the place of status.

# systemctl start nginx

And if you have to stop the service then use stop in the place of status, this will stop the service of the Nginx.

# systemctl stop nginx

If you have made any changes in the configuration file then you can reload the Nginx by using below command.

# systemctl reload nginx

Suppose you have to start and stop the service of Nginx then use restart.

# systemctl restart nginx

STEP 3: Check the IP and put that into the browser to get the Nginx Page.

Command for IP 
# ifconfig

You can see the red highlighted part in the above image that is our IP “192.168.0.104”.

So we got the Nginx Page, let’s have a look at the Nginx configuration files.

So the configuration folder is “/etc/nginx” and in that the highlighted part is the configuration file and folder.

STEP 4: Host our own website in Nginx.

So the folder is “/usr/share/nginx/html” in which we will host our website, but first, we will delete the files and folder in that directory.

Command 
# rm -rf *

This will delete all the folder and files in the /usr/share/nginx/html directory.

Create one file named as “index.html” and we will write some basic html code.

<h1>Welcome to Tastethelinux!!!</h1>
<title>Learn new Technology</title>

Just save and quit the file and refresh the browser and you will see your website. You can see the title and the heading in the HTML code

Learn about the cd command used in this POST.

Give your valuable time