- Okay, so in this lab,
we need to reconfigure the httpd service.
Now the fact is that we have already
applied quite some configuration to httpd.
And let's change it the nasty way.
First, I'm going to make sure
that we use systemctl stop httpd.
Can't be running.
Double checking.
It's not running.
Now I am going into
/etc/systemd/system/ where we have
httpd.service.d.
In which there is override.conf.
Now the httpd service, like anything is configured
in such a way that it's checking
if there is an /etc/systemd/system/
name of the service service.d directory.
And if there is, it's going to include it.
Now, if there is not, rm -rf on httpd.service.d
it's not going to include it.
Now this is one of these cases where you really must do
a systemctl daemon-reload.
Just to make sure that systemctl
is fetching the latest configuration
and it'll accept the fact
that you have just removed everything.
So what is happening if we now use systemctl cat
on httpd.service?
Well, as you can see there is just httpd.service
and that's exactly what we want.
We don't have any of this additional configuration anymore.
I mean the auto restart option is a very nice option,
but not if a service is triggered by a socket
then there shouldn't be any auto restart.
And just for sanity reasons,
I also kicked out the vsftpd service that had required.
And now we can move on and we can make sure
that the service is going to be triggered
while traffic is hitting port 80.
Now before doing so, it's nice
if we have some configuration.
So echo hello world >
/var/www/html/index.html.
That's a simple index html.
Otherwise we are starting an httpd service
that doesn't have any content to service
and that doesn't make sense.
Now let's check out if there is any sockets that we can use.
systemctl list-unit-files -t socket
is showing us all the different sockets.
And now look at that.
We even have an httpd.socket.
That's even better.
Before using it, systemctl cat on httpd.socket
is showing us what?
Is showing that this really has everything that we need.
So I'm just going to use
systemctl enable --now httpd.socket
to start the socket.
And next I am going
to access it using
curl http://localhost,
which is giving me hello world.
And systemctl status httpd,
do we see anything?
Yeah, we see it is running
triggered by httpd.socket.
So this is really telling us that it is running
since seven seconds ago triggered by the socket.
And that's exactly what we wanted.
This is what we are using sockets for.