CompTIA Linux+ XK0-005 – Unit 13 – Web Environment part 2

  1. Demo – Configuring Apache

All right, we’re going to look at the configuration file for Apache. And I’m going to do this by opening up a text editor. You know, I’ve done a lot of VI this, VI that and less this. And so, you know, let’s just go have some fun with one of these other ones. So I’m going to click Open, and in the open we’re going to follow our file system, the Etsy folder folder and Apache two. And we’re going to go to the Apache configuration file and open. There it is. There’s my file. Now I’m going to scroll on down through this just a little bit and we can see some section one global environments server route, in this case of where this is located. As I keep going through here, time out until you receive a timeout message that looks like it’s kind of a global setup.

Let’s take a look here for something more exciting as I keep going through here. Here we go. Access file name. So Access file name is the file to look for in each directory for a directory for configuration directives. It’s also got My allow overrides, and that’s one of those extensions or files that you pretty much want to keep hidden. We don’t want people to be able to see those files, so that’s important to look at. Now, when you see these files, it is your directory level configuration. And if you were to purchase, let’s say, a commercial website, you could have or even yourself, configure this website through the directives that you put into that file. So it might be one that you want to take a look at a little bit later.

Again, you’ll notice that we’re saying any file that starts with that HT, we’re basically saying nobody’s going to get in there except for the root person. All right, let’s go down here and take a look at the error log. This is important, where your error logs are going to be stored so you know the paths and the names of the files. We also can see the level in which we are going to include any issues or any type of facility. So the log level is going to start off with a warning. And this is nice. It goes from level seven, which is debug all the way down to zero. So it’s kind of listed for you in this order. And we’re saying we basically want to look at this stuff in our log level from warning on actually, no, yeah, that’s right, from Warning.

So that’s the area they want to go from Warning on down to emergency. All right, let’s take a look at any other information that we might oh, log format. There we go. It’s going to tell you basically the format by which we’re going to record information in those logs. Now let’s just hop on down to the very end and when we get to the very end of the file here it says we’re going to find all of the include statements anyway of the directory. So this is going to say or the other files. So we have this configuration D and we have this sites enabled file that might also be very important to us to know what’s in them or to work with them. So those are all the files that are basically site enabled information as you’re working with Apache.

All right. So now we’re going to try to open up the next file. Let me close this particular file and open the next one is going to be back into Apache two. So I should have probably just kept where I was at. So there’s the file system that we needed to get to and then we’re going to go to the Etsy Apache Two. And the next file that we want to take a look at is under sites enabled and is the Oo default. So in this particular one we’re going to see some information that helps us understand what’s happening on this particular port 80 connection which is our default. Anyway, the document route is telling me where all of the files that would be edited and viewed if somebody were to come to our Www site, that’s where they would go.

They’d find their index HTML file there. If I wanted to I could edit these and create more virtual hosts with different port numbers. So you have some good options here as far as what you can make changes to. Again, the document route is going to be in this location which is where we would upload our files if we were trying to make some changes. The directory now if you can’t tell the way this is set up is that basically I have an open tag and a closed tag for a lot of these different places and that’s kind of putting us into some would say a very well formed HTML type of setup. I wouldn’t know to say that this is quite an XML type of setup because normally we’d have tags for each of these other lines.

So if you’re trying to look for something that’s XML like you would have a bunch of other tags like these directory tags and these are just sections that are going to be read. And anyway, the next one, the directory here is something that’s going to apply to the files on my server’s root directory and any of the subdirectories. And so you’re seeing a lot of the directory commands going right to basically the root directory, the script alias information and the directory section after it will define where the CGI information is going to be located. So at this point, then you can go through there and figure out the options, the views, the order, as far as who can have access, who do you deny to directory structure again, and information about CGI scripting.

And it just kind of continues to take you on down there and allowing you to look at all of the rest of the information for the default sites. All right. So now we’re going to close this down. We took kind of a little tour of the editing and we’re going to go back to our terminal window and we’re going to use the G edit and we’re going to go grab now you might recognize this path. This is the home directory basically of our files. And I’m going to go and grab the index HTML. So it opened up my text editor that I just closed with the G Edit. And we know already that it does say it works. That was one of the things that was put in there. It appears anyway, to be a header file. And so what I’m going to do is I’m going to actually drop it down here.

It actually doesn’t matter if I put spaces and enter keys in between these settings because it doesn’t matter. It’s just a tag. It’s reading it in whatever order I put it in here. But I am going to type in a new paragraph and the new paragraph is going to say and Apache is cool. Two exclamation point. And then we put in the ending tag. So the ending tag has that forward slash before it. And I think we’ve just pushed the end of my knowledge anyway of HTML. So let’s save the changes to that file and now we’ve saved those changes. Let’s see if that information we learned about where those things were.

Let’s look what happens if we go to our local route or local host. And here’s local host saved in my history. And you can see that we changed that default file. So it also says, and Apache is cool too. All right. So that was just kind of a tour anyway of configuration files and information you can discover about Apache and even talked about that root directory. And we looked at that default file and made some changes as well. So I hope it gave you a good beginning start of understanding where everything is located and how you might make some changes to any of the settings about Apache.

  1. Apache Modules Part 1

Now, one of the cool things about Apache is you can addon functionality through these things they call modules. Now, a module is just that. It’s a component that you add on, whether it’s one that comes from Apache, one that comes from some other third party, whether you got it free or purchased it, or maybe you made it yourself. But these addon components were designed to add extra functionality to your web server. As an example, the support for PhPs server side programming could be added through a module.

Now, these Apache modules are going to be available to you in three different types, and we often call them Core and other modules provided by Apache and add on modules that could come from a third party developer. So when you look at them, you’re going to have to say, all right, do I really trust the module? Has it been very well tested? Did you make it yourself?But those are some of the options that you’re going to look at when you’re saying, okay, well, this module sounds pretty good. Now, here’s where I’m going to talk about security for just a second.

I would hope you thoroughly test each module if you don’t trust the authorship or the people that are distributing it before you actually put it out into production. One of the weakest things we have in web pages, because that’s one of the most highly attacked areas in our network, is having these modules that have haven’t been well tested. I mean, even large companies that do this professionally have released modules or programs or add ons that suddenly had OOH, a vulnerability we didn’t think about. So always try to test them to make sure you’re as safe as possible. Keep up to date with their updates or with any patches as well.

  1. Apache Modules Part 2

Now when we talk about these core and other types of modules, some examples might be like this module called the Mod deflate. Now remember, these are just a couple of examples of core and other modules. The Mod deflate would enable your server to be able to compress data before it sends it to the client. The mod SSL, this is a good one to have. It allows you to use SSL connections to your server, especially important if you have have secure content, banking, credit card transactions and that kind of stuff.

And of course there’s going to be any number of third party modules. You can go to Apache’s website yourself and be able to see all sorts of modules you can download. And I’m sure just a simple Google or Bing search is going to show you many other third party modules that you can use. Maybe some for trial, maybe some for you’re having to pay for them. But remember, test these before you put them into production.

  1. Apache Daemon

Now, when you’re working with Apache, like any other service, it has its own daemon that’s running, and you can look at it and work with it. With the Apache control command that’s the old one. Or just the Apache command, which is new. What does it mean? It means that with any daemon, you have to be able to do a start, stop, restart, or a nice graceful exit. Now, let me talk about that. If you want your web server to run, you have to start the service if it’s running and you need to turn it off for whatever reason, maintenance, reprogramming, whatever, you can stop it. The bad thing about stop is it does it. It stops it right there on the spot. If you have people in the middle of transactions and doing something, it’s gone, and it could cause some problems.

So graceful is a nice way of slowly bringing everything down to a close. Don’t allow anything new, get everything else out of there, and then, boom, you can shut the thing down. And, of course, restart. That’s what I call the swift kick in the power cord. Sometimes software, for whatever reason, just goes nutty. That’s a nice technical term, by the way, nutty. And so you have to restart the thing, which you could also have just stopped and started if you want. But restart means you don’t have to hang around and wait for the stop to stop. Or yes, I think I said that right. Or the start to start. You just type in restart. There it goes.

  1. Demo – Installing the PHP Module

Well, we’re still on the topic of Apache only now we’re going to talk a bit about PHP and that’s a module that we’d have to enable. So let’s take a look and see if it’s even enabled right now. So we’re going to go to the list, the Apache Two mods enabled and hit Enter. And as I look through that little list, I don’t see anything about PHP. So when we hit the up arrow, own changed the mods to mods available. And as I look through there, probably should have searched a little bit for PHP, but as I look through here, I don’t see that either. So not only is it not enabled, it’s not available, which means I’m off to system. So under system administration the Synaptic package manager opened in the background there we are going to search for, you probably guessed it, PHP.

And our goal here is to install it so that we as a module so we can actually use it. So there’s the PHP market and all of the other parts that either have to be removed or installed. One of the nice things about this system is that as you can see here, you can make sure that with this tool that you do get all of your dependencies and you don’t miss anything. So I’m just going to grab a couple of these other tools, configuration files, just again, looking at some of these options. I don’t plan on showing you MySQL with it. We’re not going to do any XML, don’t need the database and we’ll date formatting. We’ll go ahead and put some of those other things in there.

So here’s where you’re going to get with your administer your programmers who do the developing in PHP and you’re going to find out from them if that’s appropriate for what you need. So I’m going to need to apply those. Now remember we had a piece that was going to be basically replaced by one of these installations of these files. So we’ll let the installation go on and then we’re going to take a look at the mods that are enabled, just like we saw before. But just because it’s enabled does not mean that it’s ready to go. We’re still going to have to reboot Apache as well. That’s just a normal part of any service. If you make changes to its configuration files, they’re not automatically applied. You do have to generally reboot those.

All right, so from here we’ll use the up arrow. Actually let’s clear the screen first and we’ll use the up arrow to find the mods enabled. And you now see PHP Five is on my list. But as I said, we need to reboot this system. So let’s go to the Etsy innet D and Apache Two and restart. All right, so you can see a little warning about some DNS and naming issues, things that you wouldn’t normally worry about on your web servers. But since we’re not out in the public domain and I haven’t registered any URLs. We’re going to just stick with knowing that we don’t have a fully qualified domain name. So that little error is not that big of a deal to us. All right, so let’s take a look at the configuration file.

Again, a little clear command. We’ll use cat this time to get to the Etsy Apache two, mods enabled and PHP five configuration file. And there you can see that it’s basically making sure that any page, anything we open that has that extension PHP phtml, PHP three, it’s just basically trying to make sure that we see that the directives are going to make sure that any page of that extension is going to actually be opened through PHP. Again, that is a technology that will look at the script and help us with I like to call it some of the eye candy that you see. All right, let’s look at another file. And this is going to be the Etsy. PHP five, Apache two. And the PHP initialization file.

Now I use this Lust command, which means I can do my page up, page down, and it might be a fairly big file. And what I’m looking for specifically here is to see what the memory limit is, to know how much is this going to take. So I’m going to use the forward slash to get into the find and I’m going to type in memory underscore limit. Then I’ll hit enter and there we go. It took me to the memory limit location at the very top of the screen, and that set up to 128 megs of memory on my server. So I think that’s appropriate since I only have 512. So I’ll quit out of there. It gets me out of the less part of it. And now we’re going to see, well, let’s make some changes.

Let’s test this out. We’re going to use a file that won’t violate the memory. We want to create a file that’s going to have a PHP extension. And in order to do that though, we have to be able to have access to the files. So I’m going to quickly do a change mod. In fact, let me do a who am I? Just to make sure I’m root. Okay, so I’m going to use the change mod seven seven to the Varww directory, which means that everything in there is going to be available for me to have access to. And the reason I did that is so I can do a quick copy command because otherwise I wouldn’t have been able to do this. And we’re going to copy the index HTML. I know this is cheating.

We’re going to copy it into the VAR www, look at that same folder. We’re just going to call it index PHP because we’re going to try to make sure that opens up with PHP. And then I’m going to edit that file. So that we know it’s different than the one I just added the line and Apache to. There we go. I just redundant hit my words. So there’s now the PHP file that I’m going to edit. And yeah, you can see I added apache is cool too. And we’re going to do some other stuff here and try anyway to see if we can add something and maybe even take advantage of some of the coding. That the scripting that comes with PHP. So we’re going to add another paragraph line here and say it is now. And then look at this.

We’re going to put in the question mark for PHP. And this is an indication that this is to be processed by PHP. So we’re going to echo and it’s going to be echoing a time, and the time is going to be based on some variable information. These are functions that the more you know about PHP, that you would find them available for you there in the manuals on how it works. And then that’s the end of the paragraph. And so now we’re going to take a look and see what that actually does for us. Hopefully it’s something cool, right? All right, we want to save that information of what we just accomplished there. And then we’re going to open up our browser. Oops, I don’t want to open it.

Save it. Let’s try it again. Save and now we’ll close this and we’ll actually quit this whole program. And now we’ll open up our ice weasel and we’re going to go to the local host again, but this time we’re going to go to the index PHP file and now we see that it works. Apache is cool. And then we even have the time format with the new word it is now. So you got to kind of see some work with doing the scripting as well with PHP. All right, so as I said, it’s kind of a nice way of knowing how you can add on extra modules, add to the effectiveness of Apache and for your developers, which I’m not one of you, can really get some cool stuff very quickly accomplished depending on how good they are at coding and working with PHP.

 

img