NGINX Web Server (Demo)

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:00
>> Hey Cybrarians and welcome back to
00:00
the Linux+ course here at Cybrary,
00:00
I'm your instructor Rob Goelz.
00:00
In today's lesson, we're going to be
00:00
discussing the NGINX web Server.
00:00
Upon completion of today's lesson,
00:00
you're going to be able to install
00:00
the NGINX web server role on both CentOS and Ubuntu,
00:00
as well as locate the NGINX configuration files.
00:00
Let's get started with some demo time.
00:00
Here we are in our CentOS environment,
00:00
and today in order to install NGINX,
00:00
we're going to use DNF.
00:00
We can use DNF or YUM to install things on CentOS,
00:00
but just for a little variety,
00:00
we're going to use DNF today.
00:00
We'll do a DNF install NGINX,
00:00
and once this starts going,
00:00
it's going to go ahead and prompt
00:00
this if we want
00:00
to install NGINX and all of
00:00
the dependencies when we're running DNF.
00:00
Of course we're going to go ahead and say yes.
00:00
we'll give it just a moment, and there we are.
00:00
We hit "Y", and now it's
00:00
going to download and install the packages.
00:00
Now, just like we saw when we
00:00
ran the Apache install in the previous lesson,
00:00
we can use the RPM command to query the list of
00:00
files that were installed with NGINX.
00:00
Let's go ahead and do that.
00:00
We've reached the end of the install,
00:00
let's go ahead and clear our screen.
00:00
Now we can do an RPM dash,
00:00
q for query, l for list on NGINX.
00:00
We'll pipe that to less just to make sure we don't have
00:00
a bunch of output on our screen that's unreadable.
00:00
[NOISE] There we go.
00:00
Lucky for us NGINX is a very small number of
00:00
files that get installed by comparison to Apache,
00:00
which had quite a few files, if you remember.
00:00
Now what we can do is, we can take a look at
00:00
the configuration file for NGINX.
00:00
Here in CentOS, we're going to find that in
00:00
etc, nginx, nginx.conf.
00:00
If we look inside this file,
00:00
we can see a bunch of
00:00
good information right off the bat here,
00:00
we can see that it's going to listen on 80,
00:00
the default server port.
00:00
It's going to use usershare nginx html as it's
00:00
document root for all of
00:00
the configuration for the web pages.
00:00
Let's go ahead and quit out of this file.
00:00
Now in order to start NGINX,
00:00
of course we need to run systemctl,
00:00
start [NOISE] nginx, and hit "Enter".
00:00
Now we can just hit "Up" on
00:00
our keyboard and change the start to say status.
00:00
Then we can see the status of
00:00
the NGINX service is running,
00:00
and it is currently set to disabled.
00:00
Another way we could do this actually is if we wanted to,
00:00
we could do systemctl,
00:00
instead of start, we could say enable dash,
00:00
dash now, and then it will kill two birds with one stone.
00:00
Not only does it go ahead and start
00:00
the NGINX service, it also enables it.
00:00
When we run the status command now we
00:00
can see that it's actually enabled as well.
00:00
Let's clear the screen and actually let's go over
00:00
to a Firefox window here.
00:00
[NOISE] If we try to go to 127.0.0.1 in this browser,
00:00
it should bring us to an
00:00
NGINX landing page, and it does.
00:00
Welcome to nginx on Red Hat Enterprise Linux,
00:00
and we see NGINX right down here.
00:00
With that, let's go ahead and take a look.
00:00
Try to do the same thing in our Ubuntu environment.
00:00
Now with that, let's go ahead and take
00:00
a look and try to do the same thing in
00:00
our Ubuntu environment and do the same thing there.
00:00
Here we are in Ubuntu,
00:00
and what we're going to do is,
00:00
do an app install.
00:00
NGINX over here in this environment.
00:00
We're going to say yes, and
00:00
we'll just see all the lovely progress
00:00
at the bottom of the page.
00:00
There we are, we're back to our screen.
00:00
Now we are going to hit "Control L",
00:00
to give us our screen back,
00:00
so we can get our space back,
00:00
get right back up to the top clear the screen.
00:00
You can say clear or hit "Control L",
00:00
they both do the same thing.
00:00
Here in order to see all the files that are installed in
00:00
a Debian system like Ubuntu. Ubuntu is Debian based.
00:00
We have to use a D package command, so dpkg,
00:00
dash L, and we're going to
00:00
find any files that are installed of NGINX.
00:00
I think this is going to be small, so we'd have
00:00
to pipe it to less will just hit "Enter".
00:00
There we go, we've just got a handful of files again
00:00
installed along with NGINX here in Ubuntu.
00:00
If we wanted to take a look at the configuration file,
00:00
we can take a look at less,
00:00
etc, nginx, nginx.conf.
00:00
But we'll notice that this is
00:00
a slightly different file here,
00:00
it doesn't really have as much information
00:00
as what we saw in CentOS.
00:00
The reason for that is that
00:00
the actual location of some of
00:00
the information that we want to see for NGINX
00:00
is in a different place when we're talking about Ubuntu.
00:00
If we don't do a less,
00:00
but actually an ls on etc nginx,
00:00
we can see a bunch of files in here.
00:00
What we're going to do is,
00:00
we're going to go into sites available.
00:00
We're going to see that there's one called default.
00:00
Let's do a less on etc, nginx,
00:00
sites available default,
00:00
[NOISE] and here are
00:00
all the lovely configurations that we're looking for.
00:00
What we'll see here is it is
00:00
listening on port 80 as well.
00:00
But by comparison to
00:00
the configuration that we saw in CentOS,
00:00
here at Ubuntu, the root is at var, www, html.
00:00
Just a few little wrinkles between
00:00
the NGINX configuration at CentOS and Ubuntu,
00:00
but that's pretty much it there.
00:00
Now at this point, let's go ahead and run a systemctl,
00:00
do a status on NGINX.
00:00
Here we can see again, just like with Apache,
00:00
that when we install this using apt on Ubuntu,
00:00
it not only installs it,
00:00
it also goes ahead and starts
00:00
the service and sets it to enabled.
00:00
Just something to keep in mind, if
00:00
you don't want that to happen,
00:00
you're going to have to probably go in after
00:00
the fact and disable something or stop it.
00:00
The last thing we need to check
00:00
here is we need to actually make sure that
00:00
this stuff has been set up in the uncomplicated firewall.
00:00
Remember, uncomplicated firewall or UFW.
00:00
We'll look at the app list on UFW,
00:00
to see what we have here,
00:00
and we see that we have an entry for nginx http,
00:00
as well as nginx https.
00:00
Let's go ahead and add nginx http,
00:00
because we haven't configured this to do https.
00:00
We'll do a UFW allow,
00:00
and then we'll say that we want to run nginx http.
00:00
To save us from doing a little typing,
00:00
I'll just paste that in.
00:00
Didn't like that because I need to use
00:00
a closing quotation mark there and hit "Enter".
00:00
There we go, that rule has been added.
00:00
Now let's take a look over here in our Firefox and
00:00
go to 127.0.0.1, and hit "Enter".
00:00
There we go, welcome to Nginx,
00:00
we've reached our landing page.
00:00
With that, we've reached the end of this lesson.
00:00
In today's lesson we covered installing NGINX,
00:00
the web server role in both CentOS and Ubuntu,
00:00
and we talked about locating NGINX configuration files.
00:00
Thanks so much for being here
00:00
>> and I look forward to seeing you in the next lesson.
Up Next