Adding the repository
Fortunately, this doesn’t have to be installed from source, as there is an official NGINX repository where the latest version can be found. To add this repository, create a new .list file with the command:

vi /etc/apt/sources.list.d/nginx.list

In that file, paste the following two lines:

deb [arch=amd64] bionic nginx
deb-src bionic nginx

Save and close the file.
Before installation, the NGINX public key must be added. To do this, issue the following commands:

apt-key add nginx_signing.key

Update and install
Once you have the key installed, update apt with the command:

apt-get update

On the off-chance you already have an older version of NGINX installed, remove it (and it’s components) with the command:

apt remove nginx nginx-common nginx-full nginx-core

If you did have NGINX installed (and your website server blocks configured), you might want to make a backup of your configuration file with the command:

cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.old

Now it’s time to install the latest version of NGINX. Do so with the command:

apt-get install nginx -y

After the installation completes, start and enable NGINX with the commands:

systemctl start nginx
systemctl enable nginx

To find out which version of NGINX was installed, issue the command:

nginx -v

You should see that (at least as of this writing), the version number is 1.25 (Figure A), which is the latest version (as opposed to 1.14 installed from the standard repositories).