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

  1. Demo – Configuring Apache’s Default Document

Well, we’re going to work on changing the default document from index HTML to index HR PHP. But we’re going to have as a backup the original one, which means that we need to edit and we’ll do a little text editing, the Apache default sites configuration file, which was that default file. And remember GM edit, the new edit is going to open it up. In there we go, a nice little text server, or text editor I should say. And we’re going to go look for this directory varw. And let’s make sure that we have the right path here as we go through this thing. And we’re going to add some extra lines in here. So what we’re going to look for is this directory varw indexes, gives me some multiuse allow override allow from all.

And what we’re going to do is we’re going to add a new line in here. So let me hit that and come in here and I’m going to add in here directory index is going to be this file index PHP. But if it doesn’t work or if it’s not found, then it’ll go to index HTML. So I’ve just added that line inside of here to basically try to, as I said before, try to make it so that when you come into the default directory, the directory index in the varw is going to put that as my startup file instead of the index HTML. But that’s listed second. So we’re hoping that it would still be found if we lost the first file. Okay, so anyway, got that set up and what we’re going to do is now that I’ve changed or saved my changes and I’ve closed everything, we’re going to clear our screen.

I like to have a clear screen when I’m using these commands for you. And we basically want to make sure that our changes that we made aren’t going to cause us some problems. So we’re going to go to the user spin, the Apache to control and we’re going to ask it to do a configuration test. I do expect to hear a complaint about my lack of a fully qualified domain name, but other than that I am hoping everything else would be just fine. So the syntax of what I typed appears to be okay and that’s remarkable because I’m good at doing a few typos when I put things in there like that, especially being case sensitive. Well now let’s do a look at the validity of these configuration files. We’re going to do another user spin Apache control with a t and this is going to test the validity of these files.

And again it’s telling me everything’s okay. The only problem I have is that we haven’t actually gone out of our way to make sure that we restart the control so that we can enable the change. I’m going to restart that particular problem. And again it was yelling at me that it doesn’t like the Fuller Quiel fi domain name, I couldn’t determine it. And it looks like we had one particular problem with the info get, but I’m not going to worry about that one just yet. I think for that particular address, we might be okay, but just to be safe, it would never hurt also to reboot Apache itself. So let’s go to the Etsy init Apache two and let’s see tab tab again to look at our options here. Yeah, it was Apache Two.

Let me quit out of this one. Apache two, and from there let’s do restart. Let’s try it from that point. Okay, still getting the errors, but what I was looking for is making sure that I was all right. The last one was the infogat again, that’s what it was. It was both of those are just reminding me that without a fully qualified domain name, that particular function couldn’t run. So, all right, I was panicking for nothing. We’re okay there, but now that I’ve restarted it, we’re going to have to test it out. We’re going to have to see what happens if I go to the browser without specifying a page. So let’s go to the Internet, open up ice Weasel. Let’s go to our local host. And if you remember, this was the index PHP page that we had because we added all that extra code. All right, so let’s come back over here.

Let’s clear our command line screen and let’s just for the fun of it, rename that index file. So we’re going to use the move command to basically do a rename, and we’re going to rename the index PHP to same location, but we’re going to call it newfile PHP. Now that I’ve renamed it, let’s see what happens if I refresh the screen on my browser. If I refresh the screen and index PHP is gone, then I expect that it’s going to run the index HTML, which was the case because that file did not have the time on there. And just to verify that, if I go to new file PHP and I hit enter, there is my new information. So you can see that we were able to pretty well determine the first of the web pages that person would go to when they first come to our site, and a nice backup page in case something happened to the first one.

  1. Topic B: MySQL Services

All right, now, we’re going to talk about your database services. And really, there’s not a lot to say because we’re not going to give you a fullfledged database administration course here. But to make sure you understand what the services are by installing this MySQL or MySQL.

  1. MySQL

All right? Now MySQL is an open source database server. As an open source it means it’s free to you and it is a database server that supports what we call a relational database. Now, relational database is just a nice way of saying that we have multiple tables that all somehow interrelate with each other. Like a list of customers that have customer numbers and a list of the orders that they’ve done that are linked by their customer number. Right? So there’s a relationship between those. Now that set up and design is something that your database people are going to put together.

And the nice thing is it works on multiple platforms. It’s not again, just a Linux. Only now as with most software, once you set it up, it has only one default account and that’s the root account. The root account having no password. So one of the first things you’re going to do probably is secure this thing down and start creating other user accounts for the different applications that are going to connect or for the different developers that are going to be able to connect in here and start working on their database.

  1. Demo – Installing MySQL and Associated Tools

All right, we are going to install the SQL Server. So as you can see, I’m at the system administration, going to open up the Synaptic package manager, and again I’m going to search for SQL. And because we’re running PHP, I think I want to make sure that I add that in there as well. So as I’m looking through this, I’m going to look for MySQL or MySQL server in this list. Here we go. Let’s see, let’s add in the admin as well. A nice little tool to add in for some of the GUI tools. We’re also going to play with the SQL GUI tools that come with PHP. So there’s the SQL Server that I wanted to get and all of the corresponding pieces that will follow with it. And let me just go through and make sure we have all of the PHP options.

I wanted the PHP Five for my SQL and I wanted the PHP admin. There we go. The PHP my Admin. So I actually have a couple of admin tools. All right, now I’m going to go ahead and apply those and click Apply. You can see 20 packages are going to come down there. Now, as it’s going through here and starts doing the setup, it might prompt me to add a couple of answers. Like this one, password for the root user. Now, this is not for the root of the Linux installation of Debian, it’s for the root of My SQL. I’m going to make the password, password one, two, three, and click on the forward, put it in again, hoping that I can type password one, two, three twice in a row.

And then it’s going to ask me, as you can see here, a couple of questions about what we’re going to use for the reconfigure, and that is the Apache two. And I think that’s all we need to deal with. We’re not doing any of the SSL or Pearl, so I’ll forward through that and now it’s going to make the appropriate changes. And when it’s done, I should have MySQL running as a service in the background. And of course it should also have a conduit, if you would, the ability to communicate with anything I might do. Programmatically on the Apache side. All right, just waiting for it to finish. Then we’ll close this up and see that we don’t have any errors or any error messages. All right, so successfully applied, so close it down. And just like that, we now have the MySQL installed.

  1. MySQL Configuration

Now, as you’re working with the configuration of MySQL or MySQL, there are a couple of different configuration files. You’ll often find them under the Etsy MySQL and it’s the Mycnf file. Or you may have to search to figure out where the Mycnf file is. If it doesn’t follow that path from that file, you will be able to set a variety of different parameters that help you manage the things like how much memory this thing is going to use. And that, by the way, is important because you don’t want it to take all of your available memory leaving other services from being starved on memory usage.

You want to know which network port it’s going to listen to if it’s not going to be the default port of 33 six, and any user account that’s going to be associated with the MySQL operations. That means other than the root account. One of the biggest things we have problems with a lot of development is that when people write the code on their web page, on the server side code to make a connection to the database server, they often use the root account to make that connection. They do that because when they’re trying to develop code, they’re not wanting to debug whether their code was wrong or if it was a security issue in connecting to the database server.

Well, okay, I’m all right with that if you want to use the root account to connect for testing your code to make sure your code works. But then I would say, now go dumb down the permissions, use a different account for making that connection so that somebody can’t take over and do start doing what we call SQL injection or SQL Script injection. It’s just, it’s nasty when people can start sending commands into your SQL Server like Drop database. You wouldn’t have a good day that time. So be careful about those user accounts. Get other ones in there besides just the route.

  1. Demo – Examining the MySQL Configuration Files

All right, we’re going to take a quick look at the MySQL configuration files. So we’re actually going to go ahead and move to the directory under Etsy for MySQL, just so you can see what’s there real quick. LS Lyft list and not a lot there, but the one that we do care about is the My CNF for the configuration file. So we’re going to open that up. We’ll use the less command. And now as we look through here, one of the first things you might want to pay attention to is what port is being listened to for the client. So port 33 six is something you’re going to need to know or something you might choose to change. And let’s take a look and see what other little settings we have in here to deal with. Okay, so the MySQL D setting says the user is going to be MySQL talks about the ProcessID file socket.

Again, there’s the port based directory database directory, where it’s going to be located, languages that are being installed. And so just again, letting you see some of the various settings that you’re going to need to know about when you’re working with SQL. Now if you really get into this, you might actually start changing the fine tuning to try to maximize the server capability of both MySQL and of Linux as a server itself. Some logging information, error logging information as I go through here, and even some security features that they’re going to talk about certificates and making secure connections. So that is the configuration file and knowing the port numbers as I said, was important. Also, some of the basic setups for those daemons is one of the things that we saw, that we examined and that we could change in the Mycnf file.

  1. phpMyAdmin

Now with most any service, you’re going to want to be able to work with the objects that are inside the database management. And I’m going to tell you, I don’t think as much as I love command line, I don’t think I want to do the command line for this work. When you go and make a connection to the MySQL server, you’re going to have a front end client. And one example is a tool called the PHP Myadmin, which is a front end client that makes a connection to the MySQL server. Now obviously, you have to log in and your permissions will be whatever you are allowed when you log in to make this connection. But it allows you to see things like the user accounts and all of those settings that I talked about creating.

Your tables, the database names, the structures that you’re going to create, whether there’s any pre created code or procedures that you create on the server itself, or any specific types of filters for viewing information. Those are things that they’re going to create and can develop graphically. And I got to tell you, that’s probably the only way to do it, because you’re not going to command line this, you probably have to program it through a bunch of transact SQL statements to be able to actually make these things. If you wanted to do it without a Gui. So in this case, I’m going to say GUI gooey gooey. That’s the way to administer this thing.

  1. Demo – Testing Your MySQL Server

All right, let’s take a look at one of these admin programs like the PHP My admin that we’re going to use the web browser to get to. And our goal is to connect to our SQL server and just at least take a rudimentary tour of the thing. So localhost phpMyAdmin, too bad the tab doesn’t work here. Now remember that I have a different username. This was root with a password of one, two, three, and click on Go and not. Now, we don’t need to remember our information. Okay, so just like that, I’m logged into my SQL through this option. On the right hand frame, you can see I have a couple of pages home log out.

There we go, the SQL query window documentation, and for PHP and for the rest of it, or I can just click on something like this MySQL, and when I click on that, suddenly you get to see really cool stuff like tables and actions with each of the tables. Now this is where you’re going to do if you’re the program, you’re going to go through a lot of your work, you’re going to be creating these tables that are part of your database. You’re going to find ways to link them together, because it is a relational database. As I said before, you may change privileges if you do a query. That means you’re going to start using the structured query language for which SQL is named to ask questions about the contents of a table.

In fact, here you can see, I can browse through a particular table just by looking at that table and look at how exciting that table is. We don’t even know what help topic ID or help keyword is supposed to be, but that was the help relation table that I just opened up. So again, until you get into there and actually create something of use, this doesn’t make that much sense about what you’re trying to get to. All right, so anyway, again, just talking about the different options that you have in MySQL, looking at the tables, playing with the search, the query, the export, the import of databases that you might have.

And as I go over to the side, you can see the number of records, the type of table it is, and again, it’s just a part of what you would see as you start dealing with that or maybe any other databases that you make. One of the nice things in the database management system is you can have other databases to kind of keep them separate from each other. So a lot of fun that you can work with and get to know how you deal with it. But that’s where I now stop talking about it and say, hey, that’s what we need to have our DBAs, our database administrators to go in there, deal with indexing making tables and everything else. But that was the My PHP admin, a nice little tool for getting into your MySQL server.

  1. Starting and Stopping MySQL

As with any type of service, you’re going to need to be able to sometimes give it that swift kick in the Powercord, which means you may have to start it, stop it, or use the restart. Now, this is going to fall under the parent process of init D. The service is called MySQL, and then you follow it with command start, stop, or restart. Now, it’s not uncommon to stop and start, especially if you’re going to do a patch update or some other type of change or addon to SQL Server. If you do that kind of installation, it usually requires that you stop it, make the update, then start it, or if there’s just an issue in performance or restart.

  1. Demo – Starting and Stopping MySQL

Well, let’s talk about starting and stopping the process of MySQL. So again, under the Etsy init D for MySQL, you would then type in stop. And if you wanted to start it again, you would type in start. And if you wanted to restart it because you wanted it to come down and come back up, you would type restart. All right? So you can see how easy it is. Like every other service, as long as you know it’s path, you can start it, stop it, and restart it. Just make sure you do who am I? That you are doing it as the route or you use the Sudo command to do it.

 

 

img