Nginx was released in 2004 and since then growing rapidly. It holds more than 30% market share in web servers.

Let’s take a look at the installation procedure for various UNIX distro.

Ubuntu

Ensure you are logged in as a root Execute the following command

It will take few seconds to install.

RHEL/CentOS

As usual, log in as a root and use the below yum command If using RHEL 8 then you may also use dnf command. It will install including the dependencies. Below snapshot from CentOS.

Installation Using Source Code

If your server doesn’t have Internet connectivity or working on the DMZ server, then you can compile from source code to install it. The following demonstration is from CentOS/RHEL.

Download the latest version of Nginx source code and transfer to the server.

Extract the downloaded file

After extract, you should see the following files and folders

Now, we are ready to configure and install it. You can control the installation location using –prefix=path parameter. Let’s install under /opt/nginx with the SSL module. Note: if you are doing this on a brand new server where the compiler is not installed then you got to install the following. Upon completion, you should see nginx is installed under /opt/nginx with the following folders. Congratulation, You have just installed Nginx!

Stop and Start Procedure

If you compiled using the source code then to start

Go to sbin folder and execute nginx

To stop If installed using repository then What next? If this is for production then do necessary hardening and security configuration and if exploring to learn then check out this online course.

How to Install Nginx in Ubuntu or CentOS RHEL  - 85How to Install Nginx in Ubuntu or CentOS RHEL  - 26How to Install Nginx in Ubuntu or CentOS RHEL  - 97How to Install Nginx in Ubuntu or CentOS RHEL  - 4How to Install Nginx in Ubuntu or CentOS RHEL  - 30How to Install Nginx in Ubuntu or CentOS RHEL  - 27How to Install Nginx in Ubuntu or CentOS RHEL  - 45