Hey everyone and welcome back. So now what I want to talk to you about is the concept
of modules within Apache. So as we know, the Apache server ultimately allows us to present
web pages to particular users that may be internal users or external users. And the
way this is done is that Apache is ultimately going to be dealing with HTML. Now the reality
is HTML is of course very widely used on the web. But what if we want to have additional
functionality added to our server? Well if we want additional functionality, we can get
this via the use of particular modules. Because in effect, all a module is going to do, it's
going to add that functionality and allow you to just simply plug it in so to speak. IE
you download a particular module and this code is going to give you that particular feature
set that you are looking for. So say for example you wanted to introduce something like say
PHP code which is different from HTML. If Apache is designed to ingest HTML, how are
you going to be able to get it to work with PHP? The answer to that is to use an Apache
PHP module. And this is exactly what the purpose of the module is all about. What we can do
then is if we download say for example a PHP module and there are many more modules than
that we don't have to use this but let's take this as an example. This means that we can
present a particular file like our index.html, we can create an index.php file and that file
can ultimately be ingested by the PHP module and that is going to effectively convert that
code into HTML which is natively understood by the Apache 2 engine. So this really is
super super cool. So let me give you an example of how this will look then shall I? So what
I will do is I will go back to that same directory that we saw before. I'll go into CD, my var
directory, my www and then my HTML page. Now as we can see here we have this index.html
file. For now what I'll do is I'll just remove this for now, type in my password, there we
go. So it's no longer there. And what I will do is I will create an index.php file, so
I'll say sudo nanoindex.php. Okay so all I've done is create some very basic PHP. All I
have here are my HTML tags, I'm specifying HTML, we have our opening tag, then our closing
tag, we have our body tag and then our closing body tag and then within here we can actually
see we have some PHP code. Now the functionality of this PHP code as you can see here is not
exactly groundbreaking, it is fairly simple but all I'm trying to highlight here is that
ordinarily this is actually not going to be interpreted correctly by Apache, thus it's
not going to render correctly. So like I say what I'll do is I'll just save this and I'll
exit out and now what I'll do is I'll go to that web page. So now I've browsed to the
web page here, look at this, look at how this is actually being presented on the screen,
this is clearly not actually rendering the correct way that we want to see, we actually
see the echo command here, you know it's kind of a mess. So what we want to do now is we
want to install that PHP module to give us this functionality so that our Apache server
can also handle PHP code and translate it into HTML which it can render. So this is what
I'm going to do then I'll go back to my terminal here and all I'm going to do is I'm going
to say sudo apt install lib apache 2 and this is of course for Debian based systems which
I am on right now and I'm going to say mod hyphen PHP basically get the PHP module for
Apache. So if I hit enter here and I say yes the installation is going to happen right
now so we begin unpacking the packages and now as we can see here we've actually set
up our Apache 2 module for PHP so this means that this functionality that we actually see
here, again if we go back in to our index.php this PHP code functionality should now be correctly
interpreted so let's go back and try reloading that web page then. So I'll go back here and
I'll just refresh the page and look at this again nothing groundbreaking here but notice
that the echo commands are not being presented on the screen they're actually being interpreted
correctly as commands i.e. things to echo onto our web page and the actual formatting
has been corrected again nothing special about this web page it is super super basic but
the concept remains the same if you want to add functionality to our Apache server we
can do so via these types of modules. So let's actually go and explore these modules a little
bit further then so what I'll do is I'll go back to my command line and I'll just escape
out here clear the screen now I'll go back to that directory etsy apache 2 now remember
we have these different directories here the mods available and the mods enabled if I go
into the mods available right here and I do an ls-l and I happen to grep for PHP we can
actually see here these particular modules these are the modules for PHP 7.2 as we can
see here that we just have downloaded giving us this PHP functionality now we happen to
know that the PHP module is working because suddenly our web page is being rendered correctly
using the PHP code but if you want to be able to quickly check this we could go into the
mods enabled folder to see if it actually is indeed enabled so I can cd out of this directory
and I go into the mods enabled directory I can do an ls-l and I can grep for PHP once again
and as we can see here the sim links are indeed present and pointing to those particular configuration
files within the mods available directory this tells us that these sim links are active and
confirms what we already know that the PHP module is indeed active indeed so really for the purposes
of the examination understand that our Apache web server whilst it might seem simple and almost
limited in what it can do understand that we can expand the feature set of what the actual server
is capable of by introducing these particular modules that add very specific functionality
to that web server ok doc so that is us for our introduction into Apache modules I hope this
has been informative for you and I'd like to thank you for viewing
you