A thorough guide to installing NGINX on a CentOS 8 server

Hafsah Robleh
4 min readMar 18, 2023

--

Hey everyone! In this quick and thorough guide, I will show you how to install NGINX on a CentOS 8 server. We will cover how to update all packages on the server, Install an NGINX Web Server, adjust the firewall rules and then finally enable the Web Server and retrieve its IP address.

Let's start by covering the basics.

What is NGINX?

NGINX ( pronounced engine-ex), is an open-source web server. It is used for a diverse multitude of purposes, including anything from web serving, media streaming, caching and more.

Prerequisites

To download NGINX on a Centos server 8, you will have to first have the server up and running. For the purpose of this demonstration, I will be using an acloud guru server. You will need a CLI interface ( a command line interface) and an internet connection.

Let's get into it!

Open a CLI interface, I have a MacBook so it is presented as the terminal. If you are on windows it will be presented as windows powershell.

To start off we will ssh (secure shell) into the server. This will allow us to connect our devices to the server, allowing the devices to communicate.

To do this you will write ssh followed by your server username, then @ the IP address of your server.

You will then be asked if you would like to continue connecting, type yes.

You will then be prompted for your password, type that in. Do not worry that you will not be able to see your password being typed, the terminal hides it.

You should then see an output like this, showing you date and time as your last login. This means you’re in! We can now get into our first step.

Updating the packages on the server

To update the packages on our Centos 8 server, we will be using the sudo command. The sudo command which stands for super user do, is a special command that allows us to temporarily have root user privileges, allowing us to do things we normally wouldn't have access to.

The sudo command we will be using is sudo dnf install nginx

dnf is the default package manager used for Centos 8. You will then be prompted for your password again.

Congrats! Now the packages are installed. We’re almost there, now to enable the packages. we will be using the sudo commands again, don’t worry you shouldn't be prompted for your password again. The commands are sudo systemctl enable nginx

Adjusting the firewall

We will now be confirmed that our server will be able to be reached externally, by ensuring our firewall rules are set to allow so. we will do this with the command sudo firewall-cmd — permanent — add-service=http

In order to confirm that our changes to the firewall were set, we’ll need to reload. we’ll do this by typing in sudo firewall-cmd — reload

Attaining your IP address

If you’ve made it this far, congrats! we’re all done. We will now just retrieve the IP address of our server. we will do this using the curl -4 icanhazip.com command.

And that's it, I hope this guide was helpful. Thanks for reading! If you have any comments or critiques I would love to hear them, comment them down below!

--

--