nginx Archives - The Linux GURUS https://thelinuxgurus.com/tag/nginx/ Learn Linux & DevOPS from THE LINUX GURUS Tue, 27 Oct 2020 15:41:29 +0000 en-US hourly 1 https://i0.wp.com/thelinuxgurus.com/wp-content/uploads/2020/01/cropped-thelinuxgurus_transparent_name.png?fit=32%2C32&ssl=1 nginx Archives - The Linux GURUS https://thelinuxgurus.com/tag/nginx/ 32 32 148921671 Beginner’s guide to NGINX SSL CONFIGURATION https://thelinuxgurus.com/beginners-guide-to-nginx-ssl-configuration/ https://thelinuxgurus.com/beginners-guide-to-nginx-ssl-configuration/#respond Tue, 27 Oct 2020 15:41:29 +0000 https://thelinuxgurus.com/?p=1247 Security is one of the main concerns that needs to be addressed on priority for all applications or websites. All websites are required to have...

The post Beginner’s guide to NGINX SSL CONFIGURATION appeared first on The Linux GURUS.

]]>
Security is one of the main concerns that needs to be addressed on priority for all applications or websites. All websites are required to have a valid SSL certificate installed in order to encrypt the data packets/traffic between users & websites. Even web browsers show a warning when we visit a website that does not have SSL certificate installed.

In this tutorial, we will discuss how we can perform Nginx SSL configuration to configure a SSL certificate to secure our websites hosted on Nginx. So start the complete process for Nginx SSL configuration but let’s discuss the prerequisites first.

Pre-requisites

Now let’s move on to Nginx SSL configuration part. We will first be creating a self-signed certificate first  & then will configure the Nginx web server to use that certificate.

Recommended Read: Create a SELF-SIGNED SSL Certificate in Linux

Also Read: How to Host Multiple Websites with Nginx in Linux


Create a self signed certificate

Create a certificate with the following command,

$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /home/shusain/test.key -out /home/shusain/test.crt

here, openssl command is used for managing ssl,

req –x509 is public key infrastructure for ssl,

-nodes, means we don’t need a passphrase,

-days 365 is the validity of the certificate in days,

-newkey rsa:2048  means cert will 2048 bit long & uses RSA as encryption,

-keyout,provides the location for private key,

-out provides the place our SSL certificate.

So now, we have our private key (home/shusain/test.key) & a self signed certificate (home/shusain/test.crt). We need both these to configure ssl certificates in nginx.

So let’s move them to a new folder for ease of administration,

# mkdir /etc/nginx/ssl

# mv /home/shusain/test.key /etc/nginx/ssl/

# mv /home/shusain/test.crt /etc/nginx/ssl/

Now let’s move on to next step i.e. Nginx SSL configuration.


Nginx SSL configuration

Now that we have the required private key and certificate with us, we configure the SSL certificate in Nginx. We can use ‘/etc/nginx/nginx.conf’ to configura the ssl in Nginx but it is advisable to create a separate file for ssl,

# vi /etc/nginx/conf.d/ssl.conf

& enter the following lines to the file,

server {

    listen 443 ssl;

    server_name example.com;

    ssl_certificate /etc/nginx/ssl/test.crt;

    ssl_certificate_key /etc/nginx/ssl/test.key;

    ssl_dhparam /etc/ssl/certs/dhparam.pem;

root /var/www/html;

index index.html index.htm index.nginx-debian.html;

}

All we have to do is to reload the nginx configuration to complete the Nginx SSL configuration & install ssl certificate in Nginx,

# systemctl reload nginx

Now we can access our website with the https followed by the website URL,

https://example.com

Since we are using a self-signed certificate, we might get a warning but we can ignore that & click on ‘Proceed anyway’ to open the website.


Additional Parameters for SSL

The above-mentioned parameters are the basic configuration for SSL, we can actually select a number of options like TLS versions. Ciphers suites as well depending on our need.

An example to additional parameters that can be used are,

server {

    listen 443 ssl;

    server_name example.com;

    ssl_certificate /etc/nginx/ssl/test.crt;

    ssl_certificate_key /etc/nginx/ssl/test.key;

    ssl_dhparam /etc/ssl/certs/dhparam.pem;

    root /var/www/html;

     index index.html index.htm;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    ssl_prefer_server_ciphers on;

    ssl_ciphers “EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH”;

    ssl_ecdh_curve secp384r1;

    ssl_session_cache shared:SSL:10m;

    ssl_session_tickets off;

    ssl_stapling on;

    ssl_stapling_verify on;

    resolver 8.8.8.8 8.8.4.4 valid=300s;

    resolver_timeout 5s;

    add_header Strict-Transport-Security “max-age=63072000; includeSubdomains”;

    add_header X-Frame-Options DENY;

    add_header X-Content-Type-Options nosniff;

}

This completes our tutorial on how to perform Nginx SSL configuration & install a SSL certificate in Nginx. Please feel free to send in any questions or queries using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

The post Beginner’s guide to NGINX SSL CONFIGURATION appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/beginners-guide-to-nginx-ssl-configuration/feed/ 0 1247
Create a SELF-SIGNED SSL Certificate in Linux https://thelinuxgurus.com/create-a-self-signed-ssl-certificate-in-linux/ https://thelinuxgurus.com/create-a-self-signed-ssl-certificate-in-linux/#comments Tue, 29 Sep 2020 07:08:56 +0000 https://thelinuxgurus.com/?p=1222 Security threats like data theft etc are on the rise & it is of utmost importance that we employ some security to avoid such incidents....

The post Create a SELF-SIGNED SSL Certificate in Linux appeared first on The Linux GURUS.

]]>
Security threats like data theft etc are on the rise & it is of utmost importance that we employ some security to avoid such incidents. This is especially true when we are trying to access some websites over the public internet & our connections are not secure.

To avoid such unencrypted data transfers, we use SSL certificates. SSL or Secure Socket Layer is a protocol that is used for securing encrypt our website traffic. This avoids data theft, even if the data would have been intercepted by a 3rd party, it will be useless to them as the encryption used to secure the traffic is quite strong. 

SSL certificates are of such importance that now almost all web browsers show a warning when we are visiting a website that does not have a valid SSL certificate in use.

The SSL certificate that is used to secure the websites on the Public internet uses SSL certificates that are signed by Certification Authorities (CA) like Comodo, GeoTrust, Symantec, etc & they charge a fee for that. And then there are CAs like Let’s Encrypt which provide SSL certificate for free but for a lesser duration.

But we might not require any of these SSLs when we are using an SSL certificate for the testing environment or for development purposes. There we can only use self-signed certificates.

Recommended Read: How to create an SSL certificate with certbot

Also Read: How to install NGINX from Source packages in Linux

In this tutorial, we will discuss how to create a self-signed certificate in Linux. Let’s discuss the process,


Create Self Signed SSL certificate in Linux


To create a self-signed certificate in Linux, we need to have packages named ‘openssl’ & ‘mod_ssl’ installed on our system. Openssl is installed by default on all Linux distributions & we can install mod_ssl with the following command,

# yum install mod_ssl

Now we can create the SSL certificate using the openssl command mentioned below,

# openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /home/shusain/ssl.key -out  /home/shusain/ssl.crt

To describe the command mentioned above, 

openssl is the command for managing SSL,

req –x509 is the public key infrastructure for SSL,

-nodes, means we don’t need a passphrase,

-days 365 is the validity of the certificate in days

-newkey rsa:2048  means cert will 2048 bit long & uses rsa encryption,

-keyout, is the location to Private key,

-out is the location for the certificate.

We need to have both  /home/shusain/ssl.key &  /home/shusain/ssl.cert to configure it in our webserver. We will be discussing how we can install an SSL certificate in our Nginx as well as Apache in our future tutorials. Please feel free to send in any questions or queries using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

The post Create a SELF-SIGNED SSL Certificate in Linux appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/create-a-self-signed-ssl-certificate-in-linux/feed/ 1 1222
How to Host Multiple Websites with Nginx in Linux https://thelinuxgurus.com/how-to-host-multiple-websites-with-nginx-in-linux/ https://thelinuxgurus.com/how-to-host-multiple-websites-with-nginx-in-linux/#respond Tue, 29 Sep 2020 06:01:26 +0000 https://thelinuxgurus.com/?p=1232 In our last tutorials, we have discussed how to install Nginx on Ubuntu using the default repositories as well from the source. In this tutorial,...

The post How to Host Multiple Websites with Nginx in Linux appeared first on The Linux GURUS.

]]>
In our last tutorials, we have discussed how to install Nginx on Ubuntu using the default repositories as well from the source. In this tutorial, we will discuss how we can host multiple websites on Nginx webserver.

Similar to how we have virtual hosts on Apache to host multiple websites on apache, Nginx has Server Blocks to host multiple websites on Nginx.

By default, Nginx has a single website server block to host the default webpage available in /var/www/html. the default document directory for Nginx. Now let’s discuss how we can host multiple websites with Nginx by using multiple server blocks.

Also Read: Create a SELF-SIGNED SSL Certificate in Linux


Creating server blocks on Nginx

The first thing we need to do is to create a separate document directory for each of the websites that we will host. We will be hosting 2 more websites, so we will create 2 more document directories for those websites,

$ sudo mkdir /var/www/example1

$ sudo mkdir /var/www/example2

We can also use some other directory, other than ‘/var/www’ to create the document directories, but we using ‘/var/www’ is for ease of management.

Next, we need to create ‘Index.html’ page for these example websites,

$ sudo vi /var/www/example1/index.html

<html>

    <head>

        <title>This is Example1.com!</title>

    </head>

    <body>

        <h1>EXAMPLE 1 WEBSITE IS WORKING</h1>

    </body>

</html>

Similarly, create index.html file for second website as well,

$ sudo vi /var/www/example2/index.html

<html>

    <head>

        <title>This is Example2.com!</title>

    </head>

    <body>

        <h1>EXAMPLE 2 WEBSITE IS WORKING</h1>

    </body>

</html>

Next, we will create server blocks to host multiple websites on the Nginx server. To make configurations, go to the following folder,

$ cd /etc/nginx/conf.d

We will now create 2 more configuration files for hosting our websites,

$ vi /etc/nginx/conf.d/example1.conf

server {

        listen 80;

        listen [::]:80;

        root /var/www/example1;

        index index.html index.htm index.nginx-debian.html;

        server_name example1.com www.example1.com;

        location / {

                try_files $uri $uri/ =404;

        }

}

Similarly create file for second websites,

$ vi /etc/nginx/conf.d/example2.conf

server {

        listen 80;

        listen [::]:80;

        root /var/www/example2;

        index index.html index.htm index.nginx-debian.html;

        server_name example2.com www.example2.com;

        location / {

                try_files $uri $uri/ =404;

        }

}

All we now need is to reload or restart the nginx server to implement the changes made to nginx server & host multiple websites on nginx,

$ sudo sytemctl restart nginx

or

$ sudo systemctl reload ngnix

That’s it, we can now access the websites from the browser. Now to access the web server using the URL hostname, we need to add the web URL in the local DNS server but we can also use the host entries in the file ‘/etc/hosts’ to access websites with the hostname.


Create host entries in ‘/etc/hosts’,

To create hosts file,

$ sudo vi /etc/hosts

192.168.100.100     example1.com        example2.com

Save the file & exit. Here ‘192.168.100.100’ is the IP address for the Nginx webserver. This entry needs to create on all the servers from which we have to access the website.

Now open the web browser & access the websites. This completes our tutorial on how to host multiple websites on Nginx using the server blocks. Please feel free to send in any questions or queries using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

The post How to Host Multiple Websites with Nginx in Linux appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/how-to-host-multiple-websites-with-nginx-in-linux/feed/ 0 1232
How to install NGINX from Source packages in Linux https://thelinuxgurus.com/how-to-install-nginx-from-source-packages-in-linux/ https://thelinuxgurus.com/how-to-install-nginx-from-source-packages-in-linux/#respond Fri, 11 Sep 2020 13:44:43 +0000 https://thelinuxgurus.com/?p=1217 Nginx web server is one of the most famous web servers that needs hardly any introduction. It is a very fast lightweight application that can...

The post How to install NGINX from Source packages in Linux appeared first on The Linux GURUS.

]]>
Nginx web server is one of the most famous web servers that needs hardly any introduction. It is a very fast lightweight application that can work not only as a web server but also as a cache server, HTTP proxy/reverse proxy, mail proxy as well as a load balancer.

In this tutorial, we will learn how to install Nginx from source on Linux i.e on Ubuntu (20.04 in particular) & CentOS  (7 in particular). Let’s first start by installing the pre-requisites first.

Recommended Read: How to install Nginx on CentOS/RHEL

Also Read:  How to install NGINX on Ubuntu


Pre-requisites

For Ubuntu

We need to install the following packages on the Ubuntu systems before we can compile nginx package from the source

$ sudo apt-get install -y curl build-essential make gcc libpcre3 libpcre3-dev libpcre++-dev zlib1g-dev libbz2-dev libxslt1-dev libxml2-dev libgd2-xpm-dev libgeoip-dev libgoogle-perftools-dev libperl-dev libssl-dev libcurl4-openssl-dev libatomic-ops-dev

For CentOS

We need to install the following packages CentOS systems,

$ yum install gcc zlib-devel openssl-devel make pcre-devel libxml2-devel libxslt-devel libgcrypt-devel gd-devel perl-ExtUtils-Embed GeoIP-devel

Now we can move to install nginx from source packages. 


Install Nginx from source


The installation of nginx from source packages is similar for both Ubuntu & CentOS. So follow the steps mentioned below.

First, we need to download the latest stable package onto our systems (currently V-1.18.0). Download it using the following command,

$ wget https://nginx.org/download/nginx-1.18.0.tar.gz

Now extract the tar file, 

$ tar zxf nginx-1.18.0.tar.gz

$ cd nginx-1.18.0

The next step is to compile the package with the following command,

$ ./configure \

–user=root \

–group=root \

–prefix=/etc/nginx \

–sbin-path=/usr/sbin/nginx \

–modules-path=/usr/lib/nginx/modules \

–conf-path=/etc/nginx/nginx.conf \

–error-log-path=/var/log/nginx/error.log \

–http-log-path=/var/log/nginx/access.log \

–pid-path=/var/run/nginx.pid \

–lock-path=/var/run/nginx.lock \

–http-client-body-temp-path=/var/cache/nginx/client_temp \

–http-proxy-temp-path=/var/cache/nginx/proxy_temp \

–http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \

–http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \

–http-scgi-temp-path=/var/cache/nginx/scgi_temp \

–with-select_module \

–with-poll_module \

–with-threads \

–with-file-aio \

–with-http_ssl_module \

–with-http_v2_module \

–with-http_realip_module \

–with-http_addition_module \

–with-http_xslt_module \

–with-http_xslt_module=dynamic \

–with-http_image_filter_module \

–with-http_image_filter_module=dynamic \

–with-http_geoip_module \

–with-http_geoip_module=dynamic \

–with-http_sub_module \

–with-http_dav_module \

–with-http_flv_module \

–with-http_mp4_module \

–with-http_gunzip_module \

–with-http_gzip_static_module \

–with-http_auth_request_module \

–with-http_random_index_module \

–with-http_secure_link_module \

–with-http_degradation_module \

–with-http_slice_module \

–with-http_stub_status_module \

–with-http_perl_module \

–with-http_perl_module=dynamic \

–with-mail \

–with-mail=dynamic \

–with-mail_ssl_module \

–with-stream \

–with-stream=dynamic \

–with-stream_ssl_module \

–with-stream_realip_module \

–with-stream_geoip_module \

–with-stream_geoip_module=dynamic \

–with-stream_ssl_preread_module \

–with-google_perftools_module \

–with-cpp_test_module \

–with-compat \

–with-pcre \

–with-pcre-jit \

–with-zlib-asm=CPU \

–with-libatomic \

–with-debug \

–with-ld-opt=”-Wl,-E”

Note:- Here we have used ‘User’ & ‘Group’ as ‘root’ but we can create a dedicated user also & use that.

Note:- We might need to add ‘sudo’ before we run this command on Ubuntu.

Now run the following commands to complete the installation,

$ make

$ make install

Note:- Add ‘sudo’ for Ubuntu OS.

This will install the nginx from source on Linux. Now we need to create the startup service so that we can manage the service using systemctl. 


Creating service file for Ubuntu

To create the service file Ubuntu, run the following command,

$ vi /lib/systemd/system/nginx.service

& add the following content to the file,

[Unit]

Description=The NGINX HTTP server

After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]

Type=forking

PIDFile=/var/run/nginx.pid

ExecStartPre=/usr/sbin/nginx -t

ExecStart=/usr/sbin/nginx

ExecReload=/bin/kill -s HUP $MAINPID

ExecStop=/bin/kill -s QUIT $MAINPID

PrivateTmp=true

[Install]

WantedBy=multi-user.target

Save the file & exit. Now reload the daemon service to load the service file for nginx,

$ systemctl daemon-reload

Now we can start the nginx service,

$ systemctl start nginx


Creating service file for CentOS

Create the following file on CentOs,

$ vi /etc/systemd/system/nginx

& add the following content to the file,

[Unit]

Description=The NGINX HTTP server

After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]

Type=forking

PIDFile=/var/run/nginx.pid

ExecStartPre=/usr/sbin/nginx -t

ExecStart=/usr/sbin/nginx

ExecReload=/bin/kill -s HUP $MAINPID

ExecStop=/bin/kill -s QUIT $MAINPID

PrivateTmp=true

[Install]

WantedBy=multi-user.target

Save the file & exit. Now reload the daemon service to load the service file for nginx,

$ systemctl daemon-reload

Now we can start the nginx service,

$ systemctl start nginx

This completes our tutorial on how to install nginx from source. Please feel free to send in any questions or queries using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

 

The post How to install NGINX from Source packages in Linux appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/how-to-install-nginx-from-source-packages-in-linux/feed/ 0 1217
How to install NGINX on Ubuntu https://thelinuxgurus.com/how-to-install-nginx-on-ubuntu/ https://thelinuxgurus.com/how-to-install-nginx-on-ubuntu/#respond Wed, 09 Sep 2020 06:40:27 +0000 https://thelinuxgurus.com/?p=1209 Nginx is one of the most famous & widely used web servers. Nginx not only acts as a web server but can also work as...

The post How to install NGINX on Ubuntu appeared first on The Linux GURUS.

]]>
Nginx is one of the most famous & widely used web servers. Nginx not only acts as a web server but can also work as a mail proxy server, reverse proxy, cache server as well as a load balancer.

In this tutorial, we will learn how to install NGINX on Ubuntu using the Ubuntu system repositories & also with using Nginx repositories.

Recommended Read: How to install Nginx on CentOS/RHEL

Also Read: Localhost 127.0.0.1 – Setup your own Web Server

So let’s get start.


Install Nginx on Ubuntu using the Ubuntu repositories


nginx is maintained on the default Ubuntu repositories & can be installed with the default package manager i.e. apt. To install Nginx on Ubuntu, run the following command,

$ sudo apt update && sudo apt upgrade -y

$ sudo apt install nginx

Once the nginx is installed, the nginx service will install by default. We can check it by running the following command,

$ systemctl status nginx

or

$ ps -ef | grep nginx

If it’s not running, we can start the server by the following command,

$ systemctl start nginx

To enable the nginx service at the boot time, execute the following command,

$ systemctl enable nginx

Once the webserver is up and running, we can also access the default webpage for Nginx. All we need is the system IP address or if you are trying to access the webpage on the localhost, then we can also access the webpage with either ‘localhost’ or ‘127.0.0.1’ as the URL.

http://IP_address_of_the_system 

or

http://localhost


Install Nginx using the Official Nginx Repositories


To install the official nginx repositories, we need to first install the keys that are used to sign the NGINX packages,

$ sudo wget https://nginx.org/keys/nginx_signing.key

$ sudo apt-key add nginx_signing.key

Next, we will add the repositories in the file ‘/etc/sources.list’,

$ vim /etc/sources/list 

deb https://nginx.org/packages/mainline/ubuntu/ <CODENAME> nginx

deb-src https://nginx.org/packages/mainline/ubuntu/ <CODENAME> nginx

Here, <CODENAME> refers to the code the Ubuntu version being used, list is mentioned below,

Trusty 14.04 LTS
Utopic 14.10
Vivid 15.04
Wily 15.10
Xenial 16.04
Yakkety 16.10
Zesty 17.04
Artful 17.10
Bionic 18.04
Cosmic 18.10
Disco 19.04
Eoam 19.10
Focal 20.04
Groovy 20.10

 

So for Ubuntu 20.04, we need to add the following entries to ‘/etc/sources.list’,

deb https://nginx.org/packages/mainline/ubuntu/ groovy nginx

deb-src https://nginx.org/packages/mainline/ubuntu/ groovy nginx

Once done, save the file & exit & run the following command to install nginx on Ubuntu,

$ sudo apt update && sudo apt upgrade

$ sudo apt install nginx

Check the Nginx service & access the webserver to access the default webpage. So this completes our tutorial on how to install Nginx on Ubuntu. In our next tutorial, we will discuss how we can create the webserver blocks to host multiple websites on a single Nginx webserver.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

The post How to install NGINX on Ubuntu appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/how-to-install-nginx-on-ubuntu/feed/ 0 1209
How to install Nginx on CentOS/RHEL https://thelinuxgurus.com/how-to-install-nginx-on-centos-rhel/ https://thelinuxgurus.com/how-to-install-nginx-on-centos-rhel/#respond Tue, 08 Sep 2020 16:14:36 +0000 https://thelinuxgurus.com/?p=1202 Nginx is one a very famous, open-source web server application that we can also use as a reverse proxy, cache server as well as a...

The post How to install Nginx on CentOS/RHEL appeared first on The Linux GURUS.

]]>
Nginx is one a very famous, open-source web server application that we can also use as a reverse proxy, cache server as well as a load balancer among other things. It is a powerful, lightweight application & also uses very few resources.

In this tutorial, we will learn how to install Ngnix on CentOS & RHEL servers. There are two ways with which we can install the Nginx on CentOS & RHEL, either using EPEL repositories or using the Nginx official repositories.

Recommended Read: How to install NGINX on Ubuntu

Also Read: Scheduling CRON Jobs with Crontab for Beginners


Install Nginx on CentOS/RHEL using the EPEL repository


Nginx packages are not maintained on the default CentOS/RHEL repositories & are available on the EPEL repositories. So we need to install EPEL repositories on it first.

We have already discussed in detail how we can install the EPEL repository on CentOS in our tutorial HERE. You can also run the following

CentOS/RHEL 6/7

# yum install epel-release

CentOS/RHEL 8

# dnf install epel-release

Once the EPEL repository has been installed, we can then install nginx with the following command,

# yum install nginx

Once the nginx is installed, we can then start the nginx service with the following command,

# systemctl start nginx

To enable the server at boot time, run the following command,

# systemctl enable nginx

When the nginx service has started, we can access the default nginx webpage with the system IP address from a browser,

http://IP_ADDRESS_OF_THE_SERVER


Install Nginx on CentOS using the Official Nginx repository


For enabling the official Nginx repositories, we need to create the repository files for nginx repos. Create a file ‘/etc/yum.repos.d/ngnix.repo’ & enter the following details,

# vi /etc/yum.repos.d/nginx.repo

[nginx]

name=nginx repo

baseurl=https://nginx.org/packages/$OS/$releaserver/$basearch/

gpgcheck=0

enabled=1

Here, we need to update the following values as per the OS type & version number, i.e.,

OS – rhel or centos

releaseserver – 6, 7 or 8

For example, the entry for Centos 7 would be,

[nginx]

name=nginx repo

baseurl=https://nginx.org/packages/centos/7/basearch/

gpgcheck=0

enabled=1

Similarly, replace Centos with rhel for rhel 7 Nginx repository. Now, all we need is to install Nginx with the following command,

# yum install nginx

Now, start the nginx service & access the default webpage.

This completes our tutorial on how to install nginx on CentOS/RHEL. You can also check our tutorial on how to host multiple websites on Nginx HERE & if you have any questions/queries, please do let us know using the comment box below.

If you think we have helped you or just want to support us, please consider these:-

Connect to us: Facebook | Twitter | Linkedin

TheLinuxGURUS are thankful for your continued support.

The post How to install Nginx on CentOS/RHEL appeared first on The Linux GURUS.

]]>
https://thelinuxgurus.com/how-to-install-nginx-on-centos-rhel/feed/ 0 1202