Apache 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
Video Transcription
00:00
>> Hello, Cybrarians. Welcome back to
00:00
the Linux plus 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 Apache Web Server.
00:00
Upon completion of this lesson,
00:00
you're going to be able to install
00:00
the Apache Web Server role in both CentOS and Ubuntu,
00:00
and you'll be able to locate
00:00
the Apache configuration files.
00:00
Let's go ahead and get started with some demo time.
00:00
Here we are in our CentOS environment to start today.
00:00
To install Apache on CentOS,
00:00
we actually have to install the httpd package.
00:00
Of course, we do that with yum install httpd.
00:00
Now, since I'm running this as my user,
00:00
I actually have to use sudo to elevate
00:00
my permissions and become
00:00
root in order to do the install,
00:00
so I'm going to do that now and type in my password.
00:00
There we go. If we hit Y,
00:00
we're going to install all these packages.
00:00
Httpd and remember,
00:00
yum will install all the dependencies
00:00
as well, so we'll hit Yes.
00:00
Now, this is going to download and
00:00
install all these packages that we need on the system.
00:00
Now, if we give this just a minute after it's complete,
00:00
what we can do next is look and see
00:00
the files that it actually
00:00
installs and we can see that it's done.
00:00
Let's clear our screen by typing clear,
00:00
you can also hit Control L to do that.
00:00
What I'm going to do now is I'm going to type
00:00
in rpm -ql,
00:00
and I'm going to do httpd
00:00
and then I'm going to pipe that to less.
00:00
Really what I'm doing here is I'm using
00:00
the rpm command and I'm using the -q option to
00:00
query the list of httpd files that were installed,
00:00
and then I'm using
00:00
command redirection and piping it to less,
00:00
so it's not just a mess of gibberish on our screen,
00:00
we can actually page through it.
00:00
There we go. We can see all of the files that were
00:00
installed with httpd package, which are quite a few.
00:00
We'll then just quit out of that.
00:00
Now, let's take a look at the configuration file.
00:00
The configuration file that
00:00
you would be looking at and working with when
00:00
you're talking about httpd
00:00
is etc/httpd/conf and then it's httpd.conf.
00:00
If we look inside of this file,
00:00
we can see a lot of good information.
00:00
For example, we can see the port that the server is
00:00
listening on is port 80 by default.
00:00
If we wanted to change that to port 443,
00:00
we could, and then we can set it up to use
00:00
SSL certificates as well.
00:00
We can also see that it's running as
00:00
user Apache and group Apache down here.
00:00
Then perhaps most importantly,
00:00
as we go down through this file,
00:00
we can find the document root, which is var/www.
00:00
That's going to be the content directory
00:00
where you're going to find everything.
00:00
Let's go ahead and quit out of this file.
00:00
To start Apache, we can start it with
00:00
systemctl start httpd and hit Enter,
00:00
and then, of course, I'm not root,
00:00
so I need to type in my password,
00:00
probably should have run that as sudo.
00:00
But now we can do a systemctl status
00:00
and see the status of httpd,
00:00
and we see that it is active and running.
00:00
Now, the very last thing that we can do is we can
00:00
actually open a browser,
00:00
on this system, we're going to open Firefox.
00:00
We can open this browser to
00:00
the just the loopback address of this system,
00:00
which is going to be 127.0.0.1,
00:00
and then what we should see is a message
00:00
displayed from Apache saying that it's installed.
00:00
There we go,
00:00
we see an Apache HTTP test server and the test page.
00:00
Now, let's take a look at Ubuntu.
00:00
Here we are in our Ubuntu environment and
00:00
installing Apache in Ubuntu is a little bit different.
00:00
For one thing, the package is actually called Apache2.
00:00
We can do an apt install apache2
00:00
to install the Apache HTTP server on here.
00:00
Again, I need to be sudo to do this, so let's do that.
00:00
I type in my sudo password,
00:00
my user password to become root temporarily,
00:00
and we say yes, we're going to go ahead and install
00:00
this and we're going to update and download everything.
00:00
We see our lovely progress bar at the bottom obviously.
00:00
Then once that's done,
00:00
we'll take a look at the files that were
00:00
installed here. That's done.
00:00
I'm going to hit Control L
00:00
to clear the screen and bring us
00:00
back up to the top so we
00:00
have more real estate to work with.
00:00
Now, remember on an Ubuntu system
00:00
or any kind of Debian system,
00:00
we're going to be talking about working with
00:00
DEB package, DPKG.
00:00
What we can do to see the files
00:00
that were part of the Apache2
00:00
package that got installed,
00:00
we can do a dkpg -l apache,
00:00
and then I'm just going to go ahead and
00:00
pipe that to less just like
00:00
we did with the httpd package.
00:00
Now, we can see all the files
00:00
and package and other things that
00:00
were installed along with the Apache2 package.
00:00
On Ubuntu, the main configuration file
00:00
for Apache2 is in a different place.
00:00
Instead of it being in etc/httpd/conf/httpd.conf,
00:00
here it is in etc/apache2 and it's apache2.conf.
00:00
If we hit Enter in there,
00:00
we can go through here.
00:00
The biggest thing we'll probably
00:00
find it here as well is going to be
00:00
the content location on this.
00:00
If we scroll down, we can
00:00
see a bunch of different things in here.
00:00
Generally, what we're going to
00:00
see are the directory like
00:00
var/www and var/www HTML is going to be the directory.
00:00
We can also see some other files
00:00
in this etc/apache2 directory.
00:00
If we just do an ls on here,
00:00
we can also see that we have ports.conf.
00:00
Let's take a look at that file.
00:00
What we need to know about working
00:00
with Apache2 is that it has
00:00
another file setup for the ports to listen to.
00:00
When we saw listen on port 80 in one file,
00:00
in httpd, in Apache,
00:00
it's actually configured in a different file,
00:00
and it looks for that SSL module
00:00
to be loaded to listen on port 443.
00:00
Let's go ahead and quit out of this file.
00:00
Now, we can check the status of
00:00
this Apache2 with systemctl status apache2,
00:00
and we can see that it's actually loaded and running.
00:00
The thing is that when you install Apache using app,
00:00
it actually just goes ahead and
00:00
starts it up and starts it running,
00:00
and it's actually even enabled it for us to start up.
00:00
You can see that right up here it says it has enabled.
00:00
One other thing we need to do though just to
00:00
ensure that we're going to be able to use this,
00:00
is we actually have to go and set this up in
00:00
the uncomplicated firewall and
00:00
verify that we have that set up and open for Apache.
00:00
We can do this by running
00:00
ufw app list to see what's available.
00:00
We can see all the different packages or
00:00
applications that are available in the ufw.
00:00
What we'll do is we'll do sudo ufw allow,
00:00
and we're going to allow Apache
00:00
and then hit Enter and it's adding existing rule.
00:00
Now, we should be able to use our browser,
00:00
again, our Firefox web browser,
00:00
and get to that 127.0.0.1 address,
00:00
and we should see our Apache Ubuntu
00:00
default page, and we do.
00:00
With that, we've reached the end of
00:00
the lesson here today.
00:00
In this lesson, we covered installing
00:00
the Apache Web Server role in CentOS and Ubuntu,
00:00
and then we took a look at the Apache
00:00
configuration files on both systems.
00:00
Thanks so much for being here and I look
00:00
forward to seeing you in the next lesson.
Up Next