1
00:00:00,000 --> 00:00:17,300
Hey everyone and welcome back. So now what I want to talk to you about is the concept

2
00:00:17,300 --> 00:00:24,800
of modules within Apache. So as we know, the Apache server ultimately allows us to present

3
00:00:24,800 --> 00:00:30,880
web pages to particular users that may be internal users or external users. And the

4
00:00:30,880 --> 00:00:37,240
way this is done is that Apache is ultimately going to be dealing with HTML. Now the reality

5
00:00:37,240 --> 00:00:43,560
is HTML is of course very widely used on the web. But what if we want to have additional

6
00:00:43,560 --> 00:00:50,760
functionality added to our server? Well if we want additional functionality, we can get

7
00:00:50,759 --> 00:00:57,280
this via the use of particular modules. Because in effect, all a module is going to do, it's

8
00:00:57,280 --> 00:01:03,439
going to add that functionality and allow you to just simply plug it in so to speak. IE

9
00:01:03,439 --> 00:01:09,239
you download a particular module and this code is going to give you that particular feature

10
00:01:09,239 --> 00:01:14,519
set that you are looking for. So say for example you wanted to introduce something like say

11
00:01:14,519 --> 00:01:22,159
PHP code which is different from HTML. If Apache is designed to ingest HTML, how are

12
00:01:22,159 --> 00:01:28,640
you going to be able to get it to work with PHP? The answer to that is to use an Apache

13
00:01:28,640 --> 00:01:34,679
PHP module. And this is exactly what the purpose of the module is all about. What we can do

14
00:01:34,679 --> 00:01:39,879
then is if we download say for example a PHP module and there are many more modules than

15
00:01:39,879 --> 00:01:43,840
that we don't have to use this but let's take this as an example. This means that we can

16
00:01:43,840 --> 00:01:52,800
present a particular file like our index.html, we can create an index.php file and that file

17
00:01:52,800 --> 00:01:59,960
can ultimately be ingested by the PHP module and that is going to effectively convert that

18
00:01:59,960 --> 00:02:07,680
code into HTML which is natively understood by the Apache 2 engine. So this really is

19
00:02:07,680 --> 00:02:13,800
super super cool. So let me give you an example of how this will look then shall I? So what

20
00:02:13,800 --> 00:02:20,680
I will do is I will go back to that same directory that we saw before. I'll go into CD, my var

21
00:02:20,680 --> 00:02:28,600
directory, my www and then my HTML page. Now as we can see here we have this index.html

22
00:02:28,600 --> 00:02:34,000
file. For now what I'll do is I'll just remove this for now, type in my password, there we

23
00:02:34,000 --> 00:02:40,760
go. So it's no longer there. And what I will do is I will create an index.php file, so

24
00:02:40,840 --> 00:02:48,719
I'll say sudo nanoindex.php. Okay so all I've done is create some very basic PHP. All I

25
00:02:48,719 --> 00:02:54,599
have here are my HTML tags, I'm specifying HTML, we have our opening tag, then our closing

26
00:02:54,599 --> 00:03:00,239
tag, we have our body tag and then our closing body tag and then within here we can actually

27
00:03:00,239 --> 00:03:05,840
see we have some PHP code. Now the functionality of this PHP code as you can see here is not

28
00:03:05,879 --> 00:03:11,599
exactly groundbreaking, it is fairly simple but all I'm trying to highlight here is that

29
00:03:11,599 --> 00:03:17,360
ordinarily this is actually not going to be interpreted correctly by Apache, thus it's

30
00:03:17,360 --> 00:03:22,280
not going to render correctly. So like I say what I'll do is I'll just save this and I'll

31
00:03:22,280 --> 00:03:27,960
exit out and now what I'll do is I'll go to that web page. So now I've browsed to the

32
00:03:27,960 --> 00:03:33,280
web page here, look at this, look at how this is actually being presented on the screen,

33
00:03:33,280 --> 00:03:38,240
this is clearly not actually rendering the correct way that we want to see, we actually

34
00:03:38,240 --> 00:03:43,840
see the echo command here, you know it's kind of a mess. So what we want to do now is we

35
00:03:43,840 --> 00:03:50,120
want to install that PHP module to give us this functionality so that our Apache server

36
00:03:50,120 --> 00:03:56,280
can also handle PHP code and translate it into HTML which it can render. So this is what

37
00:03:56,280 --> 00:04:00,240
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

38
00:04:00,240 --> 00:04:07,120
to say sudo apt install lib apache 2 and this is of course for Debian based systems which

39
00:04:07,120 --> 00:04:13,000
I am on right now and I'm going to say mod hyphen PHP basically get the PHP module for

40
00:04:13,000 --> 00:04:18,879
Apache. So if I hit enter here and I say yes the installation is going to happen right

41
00:04:18,879 --> 00:04:23,840
now so we begin unpacking the packages and now as we can see here we've actually set

42
00:04:23,839 --> 00:04:30,759
up our Apache 2 module for PHP so this means that this functionality that we actually see

43
00:04:30,759 --> 00:04:38,639
here, again if we go back in to our index.php this PHP code functionality should now be correctly

44
00:04:38,639 --> 00:04:44,239
interpreted so let's go back and try reloading that web page then. So I'll go back here and

45
00:04:44,239 --> 00:04:49,839
I'll just refresh the page and look at this again nothing groundbreaking here but notice

46
00:04:49,839 --> 00:04:55,119
that the echo commands are not being presented on the screen they're actually being interpreted

47
00:04:55,119 --> 00:05:01,399
correctly as commands i.e. things to echo onto our web page and the actual formatting

48
00:05:01,399 --> 00:05:07,039
has been corrected again nothing special about this web page it is super super basic but

49
00:05:07,039 --> 00:05:11,759
the concept remains the same if you want to add functionality to our Apache server we

50
00:05:11,759 --> 00:05:17,839
can do so via these types of modules. So let's actually go and explore these modules a little

51
00:05:17,839 --> 00:05:22,719
bit further then so what I'll do is I'll go back to my command line and I'll just escape

52
00:05:22,719 --> 00:05:29,599
out here clear the screen now I'll go back to that directory etsy apache 2 now remember

53
00:05:29,599 --> 00:05:35,079
we have these different directories here the mods available and the mods enabled if I go

54
00:05:35,079 --> 00:05:43,279
into the mods available right here and I do an ls-l and I happen to grep for PHP we can

55
00:05:43,279 --> 00:05:49,759
actually see here these particular modules these are the modules for PHP 7.2 as we can

56
00:05:49,759 --> 00:05:56,239
see here that we just have downloaded giving us this PHP functionality now we happen to

57
00:05:56,239 --> 00:06:02,000
know that the PHP module is working because suddenly our web page is being rendered correctly

58
00:06:02,000 --> 00:06:06,199
using the PHP code but if you want to be able to quickly check this we could go into the

59
00:06:06,199 --> 00:06:12,159
mods enabled folder to see if it actually is indeed enabled so I can cd out of this directory

60
00:06:12,160 --> 00:06:21,760
and I go into the mods enabled directory I can do an ls-l and I can grep for PHP once again

61
00:06:21,760 --> 00:06:28,400
and as we can see here the sim links are indeed present and pointing to those particular configuration

62
00:06:28,400 --> 00:06:33,920
files within the mods available directory this tells us that these sim links are active and

63
00:06:33,920 --> 00:06:39,120
confirms what we already know that the PHP module is indeed active indeed so really for the purposes

64
00:06:39,120 --> 00:06:44,959
of the examination understand that our Apache web server whilst it might seem simple and almost

65
00:06:44,959 --> 00:06:51,199
limited in what it can do understand that we can expand the feature set of what the actual server

66
00:06:51,199 --> 00:06:58,000
is capable of by introducing these particular modules that add very specific functionality

67
00:06:58,000 --> 00:07:03,600
to that web server ok doc so that is us for our introduction into Apache modules I hope this

68
00:07:03,600 --> 00:07:06,800
has been informative for you and I'd like to thank you for viewing

69
00:07:09,120 --> 00:07:10,579
you

