Installing NGINX Web Server on Ubuntu 18.04 LTS

Imaze Enabulele
4 min readJun 18, 2022

--

This tutorial will walk you through how to install, run and verify NGINX web server on Ubuntu 18.04 LTS

WHAT IS NGINX?

NGINX is an open source web server which acts as a multifunctional tool . You can use the same tool as your load balancer, reverse proxy, content cache, and web server, minimizing the amount of tooling and configuration your organization needs to maintain (https://www.nginx.com/resources/glossary/nginx/)

Let’s start off by connecting to Ubuntu server through your terminal . You will be prompted to put in your password

ssh username@serverhost

serverhost = Public IPv4 address

Step 1 : Update all the packages on the Ubuntu 18.04 server

Firstly, we have to update all the software packages on the server to fix security related issues and bug fixes. We enter the command below to update:

sudo apt update

You will be prompted to put in your password when you hit the enter button. After the command runs, you would see the packages are up to date .

Step 2: Install NGINX web server

To install the NGINX web server, we will use the command below:

sudo apt install nginx

You will be prompted to either continue or not based on the amount of disk space that would be used after the operation. At the end of the installation, you would be brought back to your home directory

Step 2: Adjusting the firewall

Before testing begins, its necessary to adjust the firewall software to enable access to the NGINX service

The command below shows the status of the firewall

sudo ufw status

If its inactive, we would first allow connections via specific ports that your server needs to respond.

Take note, ufw is the program for managing a Linux firewall and aims to provide an easy to use interface for the user.

sudo ufw allow http
sudo ufw allow https

After allowing connections, we can go ahead to activate the firewall

sudo systemctl start ufwsudo ufw enable

You will be prompted about disrupting ssh connections

Checking the status of firewall

sudo ufw status

Step3: Enable the NGINX web server

To get NGINX running, use the command below:

sudo systemctl start nginx

To check that NGINX web server is running , you can type in the command:

sudo sytemctl status nginx

Step 4: Verify the NGINX Service

Now we have installed and run the NGINX service, it’s time to verify that the IP address works. To get the IP address , enter the command below:

curl ipecho.net

Now we can test the IP address on your web browser

And that wraps it up !!!

CREATING A HTML PAGE

HyperText Markup Language (HTML) is the set of markup symbols or codes inserted into a file intended for display on the Internet. The markup tells web browsers how to display a web page’s words and images.

To create a HTML page we can use several editors but I’ll be using Notepad in this tutorial

Step 1: Open Notepad on your PC

Step 2: Write the following HTML code in Notepad

<!DOCTYPE html>
<html>
<body>

<h1>Heading</h1>

<p>paragraph.</p>

</body>
</html>

In this case my heading would be “Welcome to LUIT — <Orange Team>”

Step 3: Save the HTML Page

The file should be named as index.htm and the encoding set to UTF-8(this is the preferred coding for HTML files)

Step 4: View the HTML page in your Browser

When you click on the saved file , your result will look like this:

--

--