NGINX: Setup and Installation on Linux
By: Joseph Eshiett
Tags: Linux, Web Server, Ubuntu, Nginx, Computer Networking

Finally you have come this far, you have learnt the very basics of computer networking, what the internet is, how it works, what a server and client is and lots more! If you haven’t read any part of the computer networking series I think you should. Here’s a link to parts one, two, three, four and five of the computer networking series I’d highly recommend. Alright let’s get straight into it.

Image from NGINX.com

For this hands-on lab we will be using a Linux machine specifically an UBUNTU distro. Why LINUX you ask? Here are some fun facts you should know:

90% of all cloud infrastructure runs on Linux

96.3% of the world’s top 1 million servers run on Linux

Out of the top 25 websites in the world, only two aren’t using Linux

In 2021, 100% of the world’s top 500 supercomputers run on Linux.

These are all great but what exactly makes Linux the best especially for working with the cloud and web servers?

Security : You may have guessed it, yes the security in linux is top notch and easily transcends above the rest. Not easily vulnerable to viruses, because of that, linux systems do not require an antivirus.

: You may have guessed it, yes the security in linux is top notch and easily transcends above the rest. Not easily vulnerable to viruses, because of that, linux systems do not require an antivirus. Linux is lightweight. The requirements for running Linux on hardware are much less than other operating systems. Generally, most of the Linux distributions require as little as 128MB of RAM, around the same amount for disk space.

The performance on Linux systems is top notch. It provides high performance over different networks. It is capable of handling a large number of users simultaneously.

In Linux, updating the software is all in the hands of the user, unlike other OS that seem to force updates in the background. The user can select the required updates.Updating on Linux is much faster than other OS. The system updates can be installed easily without facing any issue.

There are a lot more advantages of using Linux here’s a link to see more.

Enough about Linux, let’s talk about NGINX. It has a lot of purposes it can serve:

NGINX can be used for Web serving.

can be used for Web serving. It can be used for Reverse proxying.

It can be used to cache content to improve performance.

NGINX can also be used for load Balancing.

can also be used for load Balancing. NGINX also is frequently placed between clients and a second web server, to serve as an SSL(Secure Sockets Layer) / TLS(Transport Layer Security) terminator or web accelerator.

These are some of the use cases of NGINX, there are more such as; NGINX being used with dynamic websites to help reduce the load on the application server, and also to help cache the contents of the site or web application.

Alright let’s get into it. Get your systems ready, try to follow me step by step as we walk through this.

My Desktop

Above is an image of my desktop. Beautiful right? Had to set up a lot of things to make it look like this. If you have noticed, it sort of looks like a Mac, it was set up that way. One of the cool features of Linux is it’s customizability!

Let’s begin. Inorder to install NGINX on your system you need to follow the steps below.

To get access to the Linux Terminal, perform the following command.

ctrl + alt + T

Linux Terminal

Once you are able to run the command above, your Linux terminal should be up and running. The text you see in green above is the “USER” and “USER DIRECTORY” respectively. The user was set to my name and the user directory to the same thing.

Now that your terminal is up and running, issue the following command on the terminal.

sudo apt-get install update

The command you issued above into your terminal, is simply to update the resources on your Linux system. Once you’ve issued the command it’ll prompt for your password, you can simply type that and hit ENTER.

Update complete…

Once the process is done, it should look similar to that above. The resources in the system that need updating have been satisfied. To clear your screen issue the follow command:

type 'clear'or press 'ctrl + L'

Now that your screen is clear, type in the next command below on your terminal to install NGINX on your system.

sudo apt-get install nginx

The command above will install NGINX on your computer system.

NGINX installed

As you can see in the screenshot above NGINX is already installed in my computer system.

For the next step, let’s start up NGINX by typing the following command below:

sudo systemctl start nginx

After running the following command, NGINX should start up. In order to confirm if NGINX has started up type the next command below:

sudo systemctl status nginx

NGINX is currently running…

As you can see above, next to “Active” NGINX is active and running. Inorder to leave this screen perform the following command on your keyboard, with that you should see the ‘$’ symbol once again signifying the previous process has been exited.

ctrl + C

To test to see if the server is truly running, type the URL below into your browser:

type “localhost” or “127.0.0.1"

NGINX up and running!

As you can see above, a simple NGINX web page is displayed! so meaning your web server is up and running.

If you wish to stop the NGINX server process, simply type the following command below into your terminal:

sudo systemctl stop nginx

The following command issued above stops the NGINX running process as you can see below:

The NGINX process stopped.

AS you can see in the screenshot above the NGINX process has been stopped if you try refreshing the page it keeps saying “the site can’t be reached”.

That’s all for now. I hope this post was helpful to you, if you do have any questions you can reach out to me via my email, cheers.