0

NGINX is the high performance web server and reverse proxy server. The CentOS 8 and RHEL 8 is the first version of Red Hat family by default contains NGINX packages in default repository. The NGINX can be used as a Web Server it has very low foot printing. Which allows to be run NGINX under a production environment.

Step-1 : Check whether the NGINX packages is install by default or not

[root@techbrown~]# rpm -q nginx

Step-2 : Install the NGINX package using DNF package manager

[root@techbrown~]# dnf install nginx -y

Step-3 : As soon as installation completes start the services of NGINX

[root@techbrown~]# systemctl start nginx

Step-4 : Enable the services of NGINX so that it will survive during boot

[root@techbrown~]# systemctl enable nginx

It will show given output

ln -s '/usr/lib/systemd/system/nginx.service' '/etc/systemd/system/multi-
user.target.wants/nginx.service'

Step-5 : Add the service http and https from the firewalld firewall for communicating with NGINX

[root@techbrown~]# firewall-cmd --permanent --add-service={http,https}

It will show given output

success

Step-6 : When done reload the firewall to activate the new rules

[root@techbrown~]# firewall-cmd --reload

It will show the given output

Success

Step-7 : Change Current Working Directory to the /usr/share/nginx/html

[root@techbrown~]# cd /usr/share/nginx/html/

Step-8 : Create a .html file

Create a .html file and enter the contents of web site. Here simple.html is our html file.

[root@techbrown html]# vim simple.html

Step-9 : Change Current Working Directory to /etc/nginx/conf.d/

[root@techbrown html]# cd /etc/nginx/conf.d/

Step-10 : Create a configuration file here

For ex. we create simple.conf, and put all the configuration detail of your server like, Server Name as well as  Allowed & Denied users. In this tutorial we only allowing access for server.techbrown.com. It upon the users whom they want allow or deny. Select server name and configure the conf file same as below.

[root@techbrown conf.d]# vim simple.conf

You have to filled all the configuration detail as below. with there needs in this file and go to insert mode.

server {
        listen 80;
        listen [::]:80;

        root /usr/share/nginx/html;
        index index.html index.htm;

        server_name server.techbrown.com;

        location / {
                try_files $uri $uri/ =404;
        }
}

:wq

Step-11 : Check the Configuration file.

If Some error occurred they show the problem having configured line.

[root@techbrown conf.d]# nginx -t

It will show given output

Syntax OK

Step-12 : When you completed restart the NGINX services to make changes in the effect.

[root@techbrown conf.d]# systemctl restart nginx

Step-13 : Reload the firewalld to flush the old firewall rules and implement the new one

[root@techbrown conf.d]# firewall-cmd --reload

Step-14 : Check whether the your server is running or not with the allowed domains, Using browser

[root@techbrown conf.d]# firefox server.techbrown.com

That’s all for now.

How to Configure Apache Virtual Hosts on CentOS / RHEL

Previous article

Assassin’s Creed Valhalla : Release Date, Platforms, Gameplay and Pre-Order

Next article

You may also like

Comments

Leave a reply

Your email address will not be published. Required fields are marked *

More in Linux