1
00:00:00,000 --> 00:00:17,760
Hey everyone and welcome back to another skill in the LPIC 2 certification course.

2
00:00:17,760 --> 00:00:22,600
Okay so what we're going to be focusing on in this skill right here is all about being

3
00:00:22,600 --> 00:00:25,320
able to set up a web server.

4
00:00:25,320 --> 00:00:30,280
Now there are different types of web servers available that you can use on Linux.

5
00:00:30,280 --> 00:00:36,159
The main focus for us right now is going to be an Apache web server.

6
00:00:36,159 --> 00:00:41,799
Now all Apache is, it is an open source utility.

7
00:00:41,799 --> 00:00:46,519
Now if you don't know what open source is, it just means that the source code for the

8
00:00:46,519 --> 00:00:48,519
project is widely available.

9
00:00:48,519 --> 00:00:53,600
You can actually read this source code and it's not just open to read, it's also free

10
00:00:53,600 --> 00:00:56,800
to use under the Apache license.

11
00:00:56,800 --> 00:01:01,719
So naturally this makes a very good web server to use because it's not going to cost you

12
00:01:01,719 --> 00:01:05,280
anything, you can easily see the code to see how it actually operates.

13
00:01:05,280 --> 00:01:10,719
This really is a great solution for us, especially for demo purposes and because we do want to

14
00:01:10,719 --> 00:01:14,920
be knowing this once again for the LPIC 2 certification.

15
00:01:14,920 --> 00:01:19,159
So really what is an Apache web server used for?

16
00:01:19,159 --> 00:01:20,159
We'll think about it.

17
00:01:20,159 --> 00:01:25,399
What it's going to do is going to allow us to serve up web pages so no real big revelation

18
00:01:25,399 --> 00:01:26,399
right there.

19
00:01:26,399 --> 00:01:31,519
Now what this actually means is that we can serve up these services to our internal users,

20
00:01:31,519 --> 00:01:35,920
perhaps you want to present some type of web page to them to be able to manage their own

21
00:01:35,920 --> 00:01:42,679
system or if we so choose we can present this web page as a front facing external website

22
00:01:42,679 --> 00:01:44,519
that could be reached over the internet.

23
00:01:44,519 --> 00:01:49,679
The reality is how the Apache web server is implemented is completely flexible and up

24
00:01:49,720 --> 00:01:50,720
to you.

25
00:01:50,720 --> 00:01:55,160
Now the way Apache works is by leveraging something called HTML.

26
00:01:55,160 --> 00:02:01,480
Now if you happen to have much familiarity with web development you will actually understand

27
00:02:01,480 --> 00:02:05,560
or be at least familiar with the concept of HTML.

28
00:02:05,560 --> 00:02:13,319
But if you're not familiar all HTML is, it stands for the Hypertext Markup Language.

29
00:02:13,319 --> 00:02:17,520
And all this is going to be doing is going to provide us a type of structure that we

30
00:02:17,560 --> 00:02:22,280
can use so that we can display the pages that we want on to our website.

31
00:02:22,280 --> 00:02:25,920
It is the language that our web browsers can read.

32
00:02:25,920 --> 00:02:32,800
So if on your website you want to have maybe some bullet points like point one, point two,

33
00:02:32,800 --> 00:02:34,000
so on and so forth.

34
00:02:34,000 --> 00:02:38,840
Or if you want to embed some type of images maybe say some JPEG images or you want to

35
00:02:38,840 --> 00:02:43,680
format your actual text into paragraphs whatever it may be.

36
00:02:43,680 --> 00:02:46,200
Perhaps you want to add in different headings.

37
00:02:46,239 --> 00:02:50,839
Maybe you want to use headings of different sizes for more important issues and smaller

38
00:02:50,839 --> 00:02:53,439
headings for less important issues.

39
00:02:53,439 --> 00:03:00,759
The reality is all of this can be done using HTML which like I say is what Apache is going

40
00:03:00,759 --> 00:03:01,759
to leverage.

41
00:03:01,759 --> 00:03:08,239
Now with respect to Apache actually using HTML so that we can ultimately render our

42
00:03:08,239 --> 00:03:13,879
web pages all of this hinges upon particular configuration files.

43
00:03:13,960 --> 00:03:19,840
And like so much of what we learn within the LPIC certification courses, the actual location

44
00:03:19,840 --> 00:03:23,599
of these configuration files are of primary importance.

45
00:03:23,599 --> 00:03:29,039
So we do actually want to be knowing whereabouts these configuration files that Apache is going

46
00:03:29,039 --> 00:03:30,240
to leverage.

47
00:03:30,240 --> 00:03:35,639
We need to know where exactly they are and unsurprisingly there actually is once again

48
00:03:35,639 --> 00:03:43,000
a difference depending on if you are using a Red Hat based system or a Debian based system.

49
00:03:43,000 --> 00:03:49,280
Now with respect to Debian based systems the actual package itself is simply known

50
00:03:49,280 --> 00:03:56,400
as Apache 2 and this package on Debian is going to be located within the Etsy directory

51
00:03:56,400 --> 00:04:00,159
and then within a folder simply titled Apache 2.

52
00:04:00,159 --> 00:04:05,240
So really easy to remember the name of the package is basically within the Etsy directory

53
00:04:05,240 --> 00:04:06,240
itself.

54
00:04:06,240 --> 00:04:12,280
Now things are a little bit different with respect to Red Hat based systems like I say

55
00:04:12,280 --> 00:04:17,040
the actual package itself is not going to be called Apache 2, the package is going to

56
00:04:17,040 --> 00:04:18,040
be called HTTPD.

57
00:04:18,040 --> 00:04:25,000
Now the reason for this is because in order to access web pages we are going to be actually

58
00:04:25,000 --> 00:04:29,160
accessing that data using the HTTP protocol.

59
00:04:29,160 --> 00:04:31,759
This is the Hypertext Transfer Protocol.

60
00:04:31,759 --> 00:04:34,560
This is what you see when you use your web browser.

61
00:04:34,560 --> 00:04:36,199
So this might be a little bit confusing.

62
00:04:36,199 --> 00:04:42,240
This is the transport we use to get the information and the information we are consuming is leveraging

63
00:04:42,240 --> 00:04:43,199
HTML.

64
00:04:43,199 --> 00:04:47,720
That is the difference but basically here this is just the Hypertext Transfer Protocol

65
00:04:47,720 --> 00:04:49,000
deamin effectively.

66
00:04:49,000 --> 00:04:58,280
Now on a Red Hat based system this HTTPD package is going to be once again located within the

67
00:04:58,280 --> 00:05:03,160
Etsy directory but this time in a folder called HTTPD.

68
00:05:03,160 --> 00:05:04,680
So that really is the difference.

69
00:05:04,680 --> 00:05:10,120
The package name is going to be in the Etsy directory just like we saw with the Debian

70
00:05:10,120 --> 00:05:12,040
based Apache server package.

71
00:05:12,040 --> 00:05:17,800
So these packages are going to reside within these respective folders and within these

72
00:05:17,800 --> 00:05:21,600
particular folders we are going to have like I say these configuration files.

73
00:05:21,600 --> 00:05:26,680
Now these configuration files are not just going to be one large monolithic file that

74
00:05:26,680 --> 00:05:31,240
contains absolutely everything like so much of what we see within Linux.

75
00:05:31,240 --> 00:05:36,960
These are actually going to be modular such that effectively the configuration files are

76
00:05:36,959 --> 00:05:39,120
broken up into small chunks.

77
00:05:39,120 --> 00:05:44,519
This once again like we see before makes things a lot more manageable so as opposed to dealing

78
00:05:44,519 --> 00:05:49,199
with a huge configuration file that controls absolutely everything.

79
00:05:49,199 --> 00:05:55,000
We will be dealing with more specific and smaller files that control very particular

80
00:05:55,000 --> 00:05:57,039
aspects of the configuration.

81
00:05:57,039 --> 00:06:01,519
Like I say a common theme on Linux because this architecture happens to work really

82
00:06:01,519 --> 00:06:02,719
quite well.

83
00:06:02,720 --> 00:06:08,160
Now with respect to our Debian based systems there is quite a unique directory structure

84
00:06:08,160 --> 00:06:09,440
that we have to talk about.

85
00:06:09,440 --> 00:06:13,600
The first thing that I really should mention is that the main configuration file is going

86
00:06:13,600 --> 00:06:17,080
to be one called Apache2.conf.

87
00:06:17,080 --> 00:06:23,000
Now within this configuration file we are actually going to point to additional folders

88
00:06:23,000 --> 00:06:30,360
and these folders are going to be one called sites-enabled and the other one is going to

89
00:06:30,360 --> 00:06:33,680
be mods-enabled.

90
00:06:33,680 --> 00:06:38,800
Now these actual folders are what are called simlinks.

91
00:06:38,800 --> 00:06:44,000
Now we actually talked about simlinks in the Lpik1 certification course so no doubt you

92
00:06:44,000 --> 00:06:46,600
are familiar with this concept.

93
00:06:46,600 --> 00:06:51,560
So all these folders do in effect then is point to additional folders.

94
00:06:51,560 --> 00:06:54,120
So let me show you what the relationships actually look like.

95
00:06:54,120 --> 00:06:57,080
Let's take for example this simlink first.

96
00:06:57,079 --> 00:06:59,079
So sites-enabled.

97
00:06:59,079 --> 00:07:05,359
This simlink folder is actually going to point to a folder called sites-available.

98
00:07:05,359 --> 00:07:11,959
That is the relationship right there and with respect to our mods-enabled the mods-enabled

99
00:07:11,959 --> 00:07:19,560
simlink folder this one is going to point to a directory known as mods-available.

100
00:07:19,560 --> 00:07:23,560
And within these actual folders that we see here we are going to have a whole bunch of

101
00:07:23,560 --> 00:07:28,360
configuration files that have to be loaded by the system in order to operate correctly.

102
00:07:28,360 --> 00:07:33,639
But you might be asking why even bother having these simlinks right here.

103
00:07:33,639 --> 00:07:40,319
Instead why doesn't the Apache 2.con file just not point to this directory directly.

104
00:07:40,319 --> 00:07:46,680
Well the reality is by invoking our simlinks it just simply makes things more manageable.

105
00:07:46,680 --> 00:07:52,879
So let me tell you why this is because think about it if we have our simlink sites enabled

106
00:07:52,879 --> 00:07:58,439
which really just points to this main directory of sites-available.

107
00:07:58,439 --> 00:08:04,399
If we want to temporarily disable any of the configurations that are within this directory

108
00:08:04,399 --> 00:08:09,759
right here we don't actually have to go in and delete anything here because if we happen

109
00:08:09,759 --> 00:08:14,279
to go into this directory and delete those files then we could lose them forever.

110
00:08:14,279 --> 00:08:21,040
Instead if we just want to disable that behavior all we could do is simply and temporarily

111
00:08:21,080 --> 00:08:27,400
remove this simlink and by doing this we actually haven't changed anything physically within

112
00:08:27,400 --> 00:08:32,080
this directory but we've broken the link to this directory so it's not actually going

113
00:08:32,080 --> 00:08:33,080
to be active.

114
00:08:33,080 --> 00:08:38,200
And once again if we want the configurations within this directory to once again become

115
00:08:38,200 --> 00:08:44,480
active once more well we just recreate this simlink once again to point to this file or

116
00:08:44,480 --> 00:08:49,680
this directory should I say and then all the configurations within this folder structure

117
00:08:49,719 --> 00:08:55,159
are going to be active once again the same is true of the mods enabled simlink which

118
00:08:55,159 --> 00:08:58,279
points to the mods available directory structure.

119
00:08:58,279 --> 00:09:03,839
So really this is all about making things much much easier as well as by the way much

120
00:09:03,839 --> 00:09:08,799
safer to manage because like I say you're not having to go in and physically remove

121
00:09:08,799 --> 00:09:12,199
configuration files from the actual disk itself.

122
00:09:12,199 --> 00:09:18,559
Now like I say we do have differences between Red Hat and Debian with respect to Red Hat

123
00:09:18,599 --> 00:09:24,919
we no longer have this Apache 2.conf file no surprises since the actual package is not

124
00:09:24,919 --> 00:09:26,519
called Apache 2.

125
00:09:26,519 --> 00:09:32,319
Instead you can probably guess what the configuration file is going to be called instead the main

126
00:09:32,319 --> 00:09:40,559
configuration file here is going to be HTTP.conf so a little bit different once again.

127
00:09:40,559 --> 00:09:48,000
Also with respect to Red Hat we're not actually invoking this simlink behavior instead this

128
00:09:48,080 --> 00:09:57,080
configuration file HTTP.conf this just points to a directory structure known as the conf.d

129
00:09:57,080 --> 00:10:02,519
directory and within this directory structure we have the configuration files that the web

130
00:10:02,519 --> 00:10:07,480
server needs to actually operate and we just interact with them directly as opposed to

131
00:10:07,480 --> 00:10:10,720
the way we do it on the Debian based system.

132
00:10:10,720 --> 00:10:16,679
Okay so now that we have a rough idea of how Apache actually operates within these systems

133
00:10:16,759 --> 00:10:21,120
how about we actually take a quick peek at what these configuration files do now in order

134
00:10:21,120 --> 00:10:25,919
to do so the first thing I'm going to have to do is to install the Apache web server

135
00:10:25,919 --> 00:10:31,639
package now I happen to be on a Debian based system so I'm going to install the Apache

136
00:10:31,639 --> 00:10:39,399
2 package not the HTTP package so what I will do here is I will say sudo apt update and

137
00:10:39,399 --> 00:10:46,159
I'll type in my password okay Apache 2 and I will do dash y to answer yes to the prompt

138
00:10:46,159 --> 00:10:51,639
and the installation will begin okay so now that I have actually installed this I should

139
00:10:51,639 --> 00:10:58,120
now have this directory right here so if I go into etsy and go into Apache 2 this now

140
00:10:58,120 --> 00:11:02,879
exists now what we're going to see here is what exactly I talked about remember these

141
00:11:02,879 --> 00:11:07,639
particular files say for example or rather these particular directories should I say

142
00:11:07,639 --> 00:11:14,879
the sites available the sites enabled the mods available and the mods enabled now the enabled

143
00:11:14,960 --> 00:11:22,080
ones are going to be our sim links so if I do an LS dash L on mods enabled and list everything

144
00:11:22,080 --> 00:11:28,240
in here we can see here that indeed we actually have all these sim links that point to particular

145
00:11:28,240 --> 00:11:34,559
configurations and these actually live within the mods available directory see that there

146
00:11:34,559 --> 00:11:39,919
but in mods enabled but the point to mods available and once again we can tell these are sim

147
00:11:40,000 --> 00:11:46,399
links with these little arrows the highlighting and more concretely we have the little L at the

148
00:11:46,399 --> 00:11:53,959
very left hand side right here and similarly if I just clear the screen and I do an LS dash L on

149
00:11:53,959 --> 00:11:59,719
sites enabled once again we're going to see sim links and here in this case we only have a

150
00:11:59,719 --> 00:12:06,559
singular sim link but as you'll notice it points through the sites available directory so we could

151
00:12:06,559 --> 00:12:11,879
go into these directories such as the sites available and if I do an LS right here we can see

152
00:12:11,879 --> 00:12:17,599
these are the actual configuration files that are ultimately controlling the behavior here but we

153
00:12:17,599 --> 00:12:23,799
can like I say access them within the sim link so I can go into the sites enabled directory do an

154
00:12:23,799 --> 00:12:30,679
LS we can see we have this configuration file right here if I do a sudo nano on this configuration

155
00:12:30,679 --> 00:12:36,119
file we can see a whole bunch of information so right here we can actually see that this

156
00:12:36,159 --> 00:12:43,560
particular service is going to be running on star which means on any IP address i.e. any IP

157
00:12:43,560 --> 00:12:49,320
addresses we have configured on our server this service is going to listen on any of those IP

158
00:12:49,320 --> 00:12:55,480
addresses on port 80 now port 80 is a well-known port for web access so this should come as no

159
00:12:55,480 --> 00:13:01,120
surprise but we also have some additional information here which is really quite important this one

160
00:13:01,279 --> 00:13:06,519
right here is indeed very important the document routes this is really going to be the main

161
00:13:06,519 --> 00:13:13,000
directory that is going to hold all of your files with respect to your service so within here the

162
00:13:13,000 --> 00:13:20,600
var directory www and then the html but actually going to find html files that are going to be

163
00:13:20,600 --> 00:13:28,000
ultimately rendered by the Apache service for our web pages now the other file I want to show you is

164
00:13:28,320 --> 00:13:33,639
that main configuration file we talked about remember on Debian based system this is going to

165
00:13:33,639 --> 00:13:40,600
be called Apache 2.conf so if I go back a directory right here so I'm in the Apache 2 directory I do

166
00:13:40,600 --> 00:13:46,519
an LS here is this main configuration file right here so if I open this one up as we can see here

167
00:13:46,519 --> 00:13:52,440
this is the main server configuration file for the Apache server itself if we scroll on down we

168
00:13:52,440 --> 00:13:58,440
can actually see such things as the include optional keyword which is actually specified we're

169
00:13:58,440 --> 00:14:04,200
going to load the configuration files within the sites enable directory and we can see here we

170
00:14:04,200 --> 00:14:12,120
actually have a wildcard value which is the star meaning that any file within this directory that

171
00:14:12,120 --> 00:14:18,120
ends with .conf is going to be read as a configuration file so if we go back we're going to sites

172
00:14:18,440 --> 00:14:25,039
enabled we do an LS-L any configuration files that we can see here the end in .conf which is this

173
00:14:25,039 --> 00:14:30,000
sim link here this is going to be read in and again it just points to the sites available

174
00:14:30,000 --> 00:14:36,720
directory where we have the physical location for this configuration file and like I say that Apache

175
00:14:36,720 --> 00:14:42,600
2.conf configuration file has way way way more information than we can actually cover within

176
00:14:42,759 --> 00:14:48,320
this nugget now what we actually saw within this configuration file like I say we can see this

177
00:14:48,320 --> 00:14:54,639
document root so how about we go and have a look at this particular directory then so we'll go back

178
00:14:54,639 --> 00:15:02,040
out and I'll go into my var directory go into www and then HTML if I clear the screen to a PWD and

179
00:15:02,040 --> 00:15:09,279
LS we can see this index dot HTML configuration file right here now if I happen to open this we're

180
00:15:09,279 --> 00:15:15,199
going to see a whole bunch of HTML and you don't have to worry about all of this particular

181
00:15:15,199 --> 00:15:21,559
formatting here this is HTML code you do not have to be able to be a web developer who is very strong

182
00:15:21,559 --> 00:15:27,319
on this just understand what you happen to be looking at here this is just effectively instructions

183
00:15:27,319 --> 00:15:33,360
for how our web page is going to be rendered so what we actually have here is this index dot

184
00:15:33,440 --> 00:15:39,159
HTML file like I say and this is actually going to be a default file that the Apache web server

185
00:15:39,159 --> 00:15:44,320
is going to look for and read so if everything that is in this configuration file is going to be

186
00:15:44,320 --> 00:15:49,879
read by Apache and ultimately rendered that means what we actually see in this file we could

187
00:15:49,879 --> 00:15:55,560
actually view it via a web browser now one thing I will do right now is I will check my IP address

188
00:15:55,559 --> 00:16:03,519
I'll say IP adder we can see my local address is 192 1680 44 if I browse to this address in a web

189
00:16:03,519 --> 00:16:09,839
browser we should actually see the contents of this index dot HTML page right here so let's try that

190
00:16:09,839 --> 00:16:15,679
then so I'll go to my virtual machine browser right here I'll type in the IP address 192 1680

191
00:16:15,679 --> 00:16:22,479
44 if I hit enter the browser is actually showing the Apache to default page this is ultimately

192
00:16:22,480 --> 00:16:30,519
what we see within the contents of that index dot HTML file so what I can do here is if I go in and

193
00:16:30,519 --> 00:16:36,240
I just maybe say remove this okay so it no longer exists in fact I need to do a pseudo RM so now it

194
00:16:36,240 --> 00:16:42,720
no longer exists what I'll do is I'll recreate it okay so I'll say HTML now what I'm going to do here

195
00:16:42,720 --> 00:16:49,360
is some very basic HTML now you don't have to be worrying about being able to write this HTML

196
00:16:49,399 --> 00:16:53,399
code I just want to show you a basic example here so I'm going to use these particular

197
00:16:53,399 --> 00:17:02,039
tags h1 and then a closing tag of h1 this h1 is just simply to create a heading so I can just say

198
00:17:02,039 --> 00:17:10,480
this is a big heading welcome to the page and then I can create a smaller heading using an h2

199
00:17:10,480 --> 00:17:18,960
label or an h2 tag so you've found IPv0s web server and I'll do a closing tag for h2 and I can make

200
00:17:19,039 --> 00:17:25,519
an even smaller heading using an h3 heading hope you have a great time and I'll create another h2

201
00:17:25,519 --> 00:17:31,200
heading which will be of medium size so a little bit bigger once again come back again soon okay so

202
00:17:31,200 --> 00:17:37,680
if I happen to save this file right here we now have this index dot HTML recreated if I go to my

203
00:17:37,680 --> 00:17:43,600
web page and I reload this check this out we can see here the main heading for the web page we have

204
00:17:43,679 --> 00:17:49,439
a medium size heading then a small heading then again another medium size heading now of course

205
00:17:49,439 --> 00:17:55,199
this is a very very basic web service there is nothing too savvy with the html code that we're

206
00:17:55,199 --> 00:18:00,480
seeing here but ultimately the point remains the same we have these particular configuration files

207
00:18:00,480 --> 00:18:05,599
that are ultimately going to be referencing particular pieces of html which we can feed

208
00:18:05,599 --> 00:18:11,599
into the Apache web server that can ultimately render this service which we can then expose to

209
00:18:11,599 --> 00:18:18,159
our internal users as a private web page or if we so choose expose it as a public web page to be

210
00:18:18,159 --> 00:18:24,240
consumed by regular users on the internet so that is us for our introduction into Apache I hope this

211
00:18:24,240 --> 00:18:27,519
has been informative for you and I'd like to thank you for viewing

