Configuring our first Server
In this session we will show you how to create and customize your site in your httpd configurations file.
Video Transcript
00:00Sometimes you create a server and you're only going to have one site on it but really usually
00:05you're going to have multiple sites on it. So we've created our first site but we're going to
00:09go under the assumption that there's going to be more than one site on our server. The next step
00:15that we want to do is we want to go into the configuration of httpd and add one virtual host.
00:21To do that is quite simple there's a few steps involved but the first step is again I want to
00:26access that config file as sudo not as the current user that I'm in and I want to go to that editor
00:33and I'm going to go into the httpd folder, the config folder, the conf folder, and then
00:40httpd.config. So again that would be sudo v and it's etc etc httpd conf http http.conf.
00:53Now once we open it it's it's going to be a very very big file. Now again we're not going to go
00:59into the ins and outs of how to work with v or vim better known as vim but we'll talk here and
01:06there about shortcuts just to make our life easier. Because this file is really big what we're going to
01:12do is I want to skip all the way to the bottom of the file. To make sure I'm not in insert mode or
01:18any other mode I'm going to press on the escape button just to make sure I'm out of all the
01:23different modes and then I'm going to type shift g at the same time. What that will do is going to
01:28take me all the way to the bottom of the file where we're going to see that we have here an
01:33example of a virtual host which is exactly what we're going to be doing. So I'm just going to
01:38go ahead and I'm just going to copy this the sample by just selecting it and copying it and
01:44once I do that I'm going to click on the i so I could go into the insert mode and I'm just going
01:49to break a line and give myself a little space there and just paste that same virtual host there
01:55and uncomment it. So I'm going to go through and delete all the commenting out of here so let's
02:00just do that really quickly. Okay so the first step in our virtual host and we're just going
02:09to take that initial default is the actual this element we don't really want to change in general
02:17we want to keep it the way it is and we're basically going to configure the names of the
02:21server internally but really virtually this area is for the different ip's that we might have on
02:26our server in our case we only have one ip so we're just going to leave that star they're basically
02:31saying any any ip is fine because we only have one anyways. Now for our server admin I'm going
02:37to just type in here my my actual real email in case my server needs to send me some emails
02:43so I'm just going to make sure it has direct access to one of my emails so I'm going to call
02:47this web master oh I switched the language on this gig master at zero2geek.com that's just
02:55my email put there an email probably not your personal email but one that you could identify
03:00that it's from your server. Now the document remember that we moved our route to a completely
03:05different place so what we want to do we want to delete the folder that we have here set up here
03:10and we're going to go into the home folder where every user has a new folder inside of the home
03:15where we actually created our folder and our username was demo in that demo account we had a
03:20folder called www inside of that we had their example and inside of that we had public and
03:27that is the root folder for our html page where our actual index.html file is located.
03:35The next step is for us to configure the server name and I'm just going to put here a server
03:39name so our server name is going to be www.my10.us which is just a random url one that I have that I
03:48own. Next step is we want to define where we want our log files to be in we could leave it the way
03:55it is if we want to or we could put it in a place that is more accessible for example for the user
04:01that is related to this account so for example we might want to set it to be inside of that home
04:06demo example folder but in my case I'm going to leave it the way it is I'm just going to make sure
04:12that it's going to have your this example error log and I'm just going to delete the example.com
04:17just so there's a clear connection between what this log file is and to what is it associated
04:23to for example you might not want your developer to have access to the log file if you want your
04:29developer to have access to the log file you would then change the log file location
04:33and put it in a place that is more accessible to the user such as inside of their demo account
04:38so for example if we're the demo user I might put it inside of the example folder and create
04:42here a folder called log. Now another important thing to note is all these folders must exist
04:49if the folder doesn't exist we're going to get an error so let's just make sure that we wrote all
04:53these files correctly to do that first I'm going to save here I'm going to exit by typing escape
04:58and this time around I'm going to save it by typing on shift cz so now that I have my file saved
05:04it's time for me to test to see if actually it works so this time around when I go to try to
05:09start my server and if you recall we we ended our server we closed our server not long ago
05:16so let me just init d it's inside of etc folder init.d folder and we want to go to the service
05:23httpd and we want to restart it or in our case we want to start it and by the way remember if we
05:31just uh we could have gone there directly the way we're doing it right now or we could approach the
05:37service using the service command as we've seen in a while back it goes if I gotta go back back
05:42back and try to find that because it's been a while I've been playing around here here we go
05:46so here is that where was it service http start so we could approach the service directly through
05:52the service program or we could go inside of the actual folder where the server sorry where the
05:57service is and actually start it from there but we're going to go ahead and use this convention
06:01of using the service command so we're going to type that sudo service httpd and then click on
06:07start in our case because we haven't started it yet it's now going to again ask us for a
06:12password so we're going to put in my user password and now you can see that it's starting our
06:16server without any specific problem but it's telling us that there is some sort of an issue
06:22here we have a warning it's telling us that the folder home demo www example public does not exist
06:30so let me see where are we falling short so first of all do we have the folder home we do
06:35do we have the folder demo we do www we definitely do example we do public we do as well so let me
06:44see if there's any typo here and you can see that example here i typed we're at without an a but here
06:50i typed an example adding another a inside here so again what we'll do is we're going to go back into
06:55that uh into our config file i'm going to again type shift g to jump all the way to the bottom
07:01i'm going to click on i to go into insert mode and i'm just going to go ahead and i'm going to
07:06fix that uh typo there or maybe it's a typo on the folder directory but i decided to call the
07:11folder directly without the a so i'm just going to make sure that it's all comparable even though
07:15that a should be there we're going to do this just for this practice so i'm going to escape
07:20click on shift zz to save and again i'm going to click on start but this time i want to restart
07:26so i'm going to click here restart on our service so sudo service httpd restart what it's
07:31going to do is going to it's going to stop the service it's going to then restart the service
07:36and once we restart the service our server should be connected and working in the next
07:41video i'm going to jump into my hosting into my uh domain provider because i want to configure
07:48my domain provider to send the ww to send that url to this hosting so my hosting could then
07:54capture that that um url and then know what to do with that url so we'll see you in the next
08:00video where i'm going to be right inside of my godaddy account you could do it with whatever
08:04service you want but if you have a domain and if you've done it with godaddy where you're going
08:08to see the process on godaddy but the process is very similar some domains and we'll talk about
08:13this more in the next video
