Ah, yes, our first demonstration, a demonstration where we're looking at
installing Apache on our Ubuntu 20.04 system. Along with that, of course, we're
putting our command line browser just to give me ease of access to our web
server from the command line, but we're also going to make sure that we can
resolve our hostname and interrogate the system to let me know where the
hostname is being resolved from.
Now I can begin from my command line as a standard user. We can see I've got
the hostname ubuntu. That, remember though, is just my prompt, so it's always
worth going through taking a look at hostnamectl. That gives me more
information than just the hostname, but we can see then our Static hostname of
ubuntu, so it's our configured hostname. But we can also see then that we're
using Ubuntu 20.04.4 for this one.
Okay, well, let's try and ping our hostname. If I go through then and ping
ubuntu, so that's my hostname, we're getting it coming back. If I do a Ctrl+C
on this, we'll just stop it. So this might all seem good and we could leave it
like this, we're able to ping our house, but where are we pinging it from? If
I go through and grep, let's search for ubuntu, inside of my etc and hosts
file, we can see that we're not getting ubuntu coming back, the match is on
ubuntu‑focal, not just on ubuntu. And it's coming back with the 127 address,
not the 10 address, so this is definitely not what we are resolving. We can
dig a little bit further, and I don't mean that to be a pun, but the command
is actually dig. And we can go through then and dig ubuntu. This will then go
through and tell me from where it's being resolved. And we can go through and
take a look in our ANSWER SECTION, and we're getting then two addresses coming
back, so I've got two interfaces on this, and it actually comes back with both
of the addresses from my system. But if we take a look at our server,
127.0.0.53, this is the DNS server that resolved it, so it's running locally.
If I go through and just take a look at ss ‑ntl, this will show
me the ports are open on my system, and I can see we do really
have then 53, we are listening on DNS. If we want to interrogate
the service behind that,
then I can go through and use sudo ss ‑ntl, but add the p in so I can see the
process sat behind that. And we can see then that it's being managed by
systemd‑resolve, so it's a systemd DNS resolver that is managing our name
resolution, and that includes then my hostname. So all of this then is just
showing me how we can get name resolution working.
It is important that we can resolve, at least from this host, the
hostname ubuntu. We're going to go through now and elevate our
privileges, and we can go through and do an apt update.
So this is just making sure that we've got up‑to‑date
metadata for installing our packages.
Sometimes when you try and install a package, it might
come back saying it can't find it,
but that's more likely that you've either done a little bit
of a typo or you don't have an up‑to‑date metadata regarding
the packages to be installed.
I can clear my screen. With that done,
I can go ahead then and apt install ‑y, so it doesn't stop waiting
for me to accept the package installation, and it's apache2 when
we're looking at an ubuntu system. It would be httpd if you were
using a Red Hat‑based system.
We're also going to put the command line browser, w3m, it
just gives me an easy way that I can get to my website, and
then allow this to run through.
Now I think I said in the slides that when we're
working on a Debian‑based system,
Debian‑based systems in general will go through and start and
enable our services once they have been installed.
So we should find at the end of the installation our web server is up and
running. If I clear my screen and then just go through and do a w3m
localhost, then we get our default Apache page coming back, but of course
we're going over HTTP and not HTTPS.
If I look at this system a little bit more, again,
if I close out my browser, ss ‑ntl, when we take a look at it,
it's only port 80, HTTP, that we're listening on, and there
is no HTTPS listening port currently, but this is what we're going to look at changing.