Installing a web server on Ubuntu

Video loading...

  • 0:00
    drupalize me
  • 0:04
    [MUSIC PLAYING]
  • 0:06
    Installing a web server on Ubuntu with Addison Berry.
  • 0:12
    In this video, we're going to be looking at how you can set up
  • 0:15
    your own personal web server for development
  • 0:18
    or playing around on an Ubuntu desktop.
  • 0:21
    We'll be installing Apache, MySQL, and PHP,
  • 0:25
    and this will be on Ubuntu 11.10.
  • 0:28
    Before we get actually into anything,
  • 0:31
    I want to go find the documentation for this
  • 0:33
    and show you where that is.
  • 0:34
    It's on the Ubuntu site.
  • 0:35
    We go to Support, and then you can access the free documentation.
  • 0:38
    You'll notice there are versions here for official documentation,
  • 0:42
    but we're not actually going to use those because those would install
  • 0:45
    the individual pieces, and we're going to install all of it
  • 0:48
    in one fell swoop.
  • 0:50
    And that you can find in the community documentation.
  • 0:53
    There's a lot of clicks here, and we'll put the URL up here
  • 0:56
    at the end, so you can just go directly to it,
  • 0:58
    but I want to show you how I got there.
  • 1:00
    In the documentation under software, you
  • 1:02
    can look up various applications.
  • 1:04
    Within the applications, we're going to look
  • 1:06
    up servers and web applications.
  • 1:10
    And then we go down to web servers and you'll
  • 1:14
    find Apache, PHP, MySQL, the classic LAMP stack.
  • 1:19
    And so the final URL here is help.ubuntu.com/community/ApacheMySQLPHP
  • 1:26
    and this shows us a very nice, simple app, some simple commands,
  • 1:30
    so that we can install this using Tasksel.
  • 1:35
    This has all of our basic documentation,
  • 1:37
    and note that this is for Ubuntu 10.4 and higher versions,
  • 1:42
    so any of the latest versions are going to work with this.
  • 1:45
    The first thing we're going to need to do is install Tasksel.
  • 1:48
    So here's a command line way to do it.
  • 1:50
    And then the second thing we'll do is actually
  • 1:52
    install the LAMP server using Tasksel.
  • 1:56
    Sort of a helper application that will
  • 1:59
    do these sort of multi-package installations for us.
  • 2:02
    I'm going to show you real quick how you can install Tasksel.
  • 2:08
    You can install this through a GUI using your Ubuntu Software Center,
  • 2:13
    so if I search for Tasksel in the software here.
  • 2:16
    You can see it's here, and I can just click the Install button.
  • 2:20
    Chances are, if you're doing this, you're
  • 2:22
    going to need to use command line.
  • 2:23
    You're going to have to use command line to use Tasksel itself;
  • 2:26
    it doesn't have a GUI.
  • 2:27
    So I'm not going to install it that way,
  • 2:29
    but I just want to show you it is there if you feel more
  • 2:32
    comfortable doing that, but you're going
  • 2:33
    to have to get a little dirty with the command line on this.
  • 2:37
    I'm going to go to the command line to actually install this.
  • 2:42
    Let me move this out of the way, so we can look at the command that's
  • 2:47
    in the instructions here, sudo apt-get.
  • 2:51
    This is classic command line installation.
  • 2:55
    Install, and then the name of what I want to install, which is Tasksel.
  • 2:59
    It's very hard to say that without tripping over your words.
  • 3:03
    Go ahead and put in my sudo password, and then hit yes.
  • 3:08
    It'll take it just a few quick minutes here
  • 3:12
    to actually go through the installation process.
  • 3:15
    I return to my prompt.
  • 3:16
    Now Tasksel is installed.
  • 3:19
    That's step one.
  • 3:21
    Step two is to now actually install the LAMP server with our new tool
  • 3:26
    that we just installed.
  • 3:28
    We will move this out of the way.
  • 3:29
    There's my second command, right?
  • 3:32
    It's very similar to the one we just ran for APT get.
  • 3:35
    This is sudo Tasksel, install, and then what we want to install from,
  • 3:41
    from within that tool, which is the lamp-server.
  • 3:47
    I'm going to go ahead, run this installation.
  • 3:50
    This one will be a little more involved.
  • 3:52
    It's going to pop up like a little wizard and ask us a few questions.
  • 3:57
    It needs to pull down the packages and as it sort of unpacks them
  • 4:00
    and get them going, it will ask us some questions about configuration
  • 4:03
    that we will need to take care of.
  • 4:08
    As we go along, we need to set up our MySQL
  • 4:11
    root user, who is the super user here.
  • 4:14
    I'll just type in a password, which you really should remember.
  • 4:18
    It asks you to repeat it.
  • 4:20
    It's really important to not forget your MySQL root user.
  • 4:23
    It's kind of a pain to have to reset that.
  • 4:26
    Once we get through the installation,
  • 4:28
    there we go, now we should have a web server,
  • 4:32
    and it should be running.
  • 4:34
    I'm going to go to my browser in a new tab here and go to local host.
  • 4:38
    And it is working.
  • 4:39
    Our LAMP stack, the entire LAMP stack, has been installed
  • 4:42
    and the server is running for us, so that's pretty awesome.
  • 4:48
    So that's just getting things initially installed.
  • 4:50
    I'm going to point out a few of the things,
  • 4:52
    one is that you should use Tasksel to install,
  • 4:56
    but not to uninstall or remove.
  • 4:58
    If you want to remove your LAMP stack,
  • 5:00
    they have instructions for this, all of the individual packages
  • 5:03
    that really should be removed.
  • 5:05
    And if you didn't want to use Tasksel,
  • 5:07
    you could just manually apt-get install all of those packages.
  • 5:10
    This is essentially doing the same thing.
  • 5:13
    It's just Tasksel is doing that for you.
  • 5:16
    Also, I want to show in the documentation here,
  • 5:19
    that under that initial stuff, there's all of this documentation
  • 5:22
    on doing the individual pieces, as well.
  • 5:26
    The easy way is Tasksel, but all the detailed stuff
  • 5:29
    is still there, as well, if you want that.
  • 5:32
    And then, lastly, I want to point out is phpMyAdmin.
  • 5:34
    That's a common tool that a lot of people
  • 5:36
    like to use to manage their database.
  • 5:39
    We have to install phpMyAdmin.
  • 5:40
    It's pretty much what the instructions say.
  • 5:42
    So again, this is another application,
  • 5:46
    we can go into the Software Center and I
  • 5:48
    can install phpMyAdmin from here.
  • 5:51
    Click the Install button and it'll install it.
  • 5:54
    That's fine.
  • 5:55
    Since I've started in command line, I'm
  • 5:56
    just going to continue that way.
  • 5:58
    I just want to show you that.
  • 5:59
    So again, this is just an apt-get install, sudo apt-get install,
  • 6:04
    for phpMyAdmin.
  • 6:07
    And it's going to go ahead and run through the classic.
  • 6:09
    I say, yes.
  • 6:11
    And this is also going to ask us for a little bit
  • 6:13
    of configuration information.
  • 6:17
    It needs to know what kind of web server
  • 6:19
    is phpMyAdmin supposed to run with, Apache,
  • 6:23
    since this is what we're doing.
  • 6:25
    And then, I need to configure phpMyAdmin
  • 6:28
    and basically, this is saying, unless you know what you're doing,
  • 6:30
    just follow the instructions in the wizard.
  • 6:32
    So, that's what we're going to do.
  • 6:35
    Yes, I do you want to follow the wizard here.
  • 6:39
    And I need to have a password for the database administrative user,
  • 6:44
    which is what we created the last time when
  • 6:46
    we were installing the LAMP server.
  • 6:48
    And then, that's the password for MySQL itself.
  • 6:53
    Password confirmation.
  • 6:55
    Just remember these passwords.
  • 6:57
    Make sure that you have passwords that you can remember
  • 7:00
    so you can get access to this stuff.
  • 7:04
    Now phpMyAdmin is installed.
  • 7:06
    If I go to localhost/phpMyAdmin, that's now installed and running.
  • 7:14
    It doesn't come with part of the LAMP server Tasksel installation,
  • 7:18
    but it's very easy for you just add your own phpMyAdmin.
  • 7:21
    I'll log in here.
  • 7:23
    Ta-da!
  • 7:23
    I can manage my database through a GUI if I'd like to.
  • 7:27
    OK, so we have all the working pieces in place.
  • 7:31
    But now we need to actually use it.
  • 7:33
    I have local host, that's great, but what
  • 7:35
    if I want my own website files in here.
  • 7:37
    Let's take a look at where stuff is, and how
  • 7:40
    to add our own web information in here.
  • 7:44
    The location for the server is at var www, slash bar starting
  • 7:51
    from the root, and you'll see index.html
  • 7:53
    is the only thing that's in there, and that is what is displaying our,
  • 7:56
    "It works!" page when we go to local host, because that is our web root.
  • 8:02
    We can also look at the web root in just our regular folders here.
  • 8:09
    I open this up, then we go to the file system
  • 8:11
    because we have to come back out of my user directories.
  • 8:15
    We can go to var www, that's the web root,
  • 8:19
    and there's the index.html file.
  • 8:22
    Now let's say I wanted to start adding some stuff.
  • 8:26
    Go in and create a new folder for a new website.
  • 8:29
    It's grayed out and I can't.
  • 8:31
    I don't have permission to actually access this.
  • 8:35
    This is not in my user directory.
  • 8:37
    So, we'll need to take a look at that.
  • 8:40
    I'm going to go back to my terminal here,
  • 8:44
    and we'll look at it from this side.
  • 8:48
    So again, I can try and make a directory,
  • 8:50
    but I'm getting this actual error now, which says permission denied.
  • 8:55
    Let's go up and look at the permissions.
  • 8:57
    I'm doing a list all here.
  • 8:59
    And you can see that the www directory is
  • 9:03
    owned by root, because root installed it.
  • 9:05
    We're doing all the sudos.
  • 9:06
    You need root to do all these installations.
  • 9:10
    But now my web root is also controlled
  • 9:14
    by root, and not by my users.
  • 9:17
    I have to use sudo to do everything or I can change the ownership
  • 9:22
    of just my web root to my owner, which
  • 9:26
    in this case, my account, which happens to be parallels.
  • 9:30
    Now you can see I did a chown just on the web root folder
  • 9:34
    to my account, so I don't have to keep doing sudo and deal
  • 9:37
    with all the permissions problems.
  • 9:38
    That's a personal choice for you.
  • 9:40
    This is my local, so I'm not too worried about a ton of security
  • 9:43
    around my web root.
  • 9:46
    If I go back in here now to my web root,
  • 9:49
    you'll see that I can now make a directory
  • 9:51
    and I don't get permission denied.
  • 9:52
    And we can go back over here also to my file browser,
  • 9:55
    right, and in the GUI.
  • 9:57
    You can see that I've created the folder and I can get access to it.
  • 10:01
    Now, I can create new folders and documents.
  • 10:04
    I'm going to create a new document for my new website called,
  • 10:08
    "My Site."
  • 10:08
    Now I'm now at index.html, now it can be index.php or whatever.
  • 10:13
    You put your CMS files in here.
  • 10:15
    I'm going to open this up.
  • 10:18
    I'm not even really going to put html in here.
  • 10:20
    I just want to test to make sure this is working.
  • 10:22
    I'm just going to put some text in here,
  • 10:24
    "This is my new development site."
  • 10:28
    Woo, exciting!
  • 10:29
    I'll save this file, and we can go ahead and just close this out.
  • 10:35
    So again, I'm in var www, my site folder inside of my web root.
  • 10:41
    I'm going to go back to the browser and test it.
  • 10:43
    Local host is web root, www, my site folder within it.
  • 10:47
    And my index.html is displaying.
  • 10:51
    That's pretty cool, I have a website.
  • 10:55
    Now that I have this working, and I can put up many dev sites,
  • 10:59
    I don't really need this index.html in my main web root
  • 11:03
    because it's just showing a message that I don't really need.
  • 11:06
    I'll just move this off to the trash.
  • 11:09
    I could put a website directly in the root, but for development
  • 11:11
    you often have many sites.
  • 11:13
    I removed the index.html in the www folder.
  • 11:19
    And now when I go back to local host,
  • 11:20
    I don't get that text that was displaying,
  • 11:22
    but I can actually see a listing of all the folders
  • 11:25
    that are in that directory, which would be all my development
  • 11:27
    sites that I'm working on and then I can just click into the one
  • 11:30
    that I need.
  • 11:32
    OK, we have a web server installed and running
  • 11:36
    and we know where to put our files, so that we can start
  • 11:39
    creating development sites within that.
  • 11:42
    The last thing that we will need to do
  • 11:43
    is see how we can turn the server on an off,
  • 11:46
    because it was turned on for us by default,
  • 11:48
    but what if you want to turn it on or off or restart it.
  • 11:51
    So back on this documentation, and it's here.
  • 11:54
    You can search anywhere on the web to find the command
  • 11:57
    for turning the server on and off.
  • 11:59
    But, I know it's in this one page of documentation,
  • 12:02
    which is really handy, so I'll go here.
  • 12:05
    Under installing Apache 2, which is towards the top,
  • 12:08
    there's this line that shows you the commands for restarting.
  • 12:13
    You can also use that to stop it and start
  • 12:15
    it individually without a restart.
  • 12:17
    I'm going to go ahead and type that in,
  • 12:19
    so it's sudo/etsy/init.d/Apache.
  • 12:28
    Yeah.
  • 12:29
    There's other APs there.
  • 12:30
    There we go, Apache 2.
  • 12:32
    And then "stop," to stop it.
  • 12:36
    I've now stopped it.
  • 12:37
    If I go back to the browser here and I reload this page,
  • 12:40
    go up here and just reload.
  • 12:42
    It's not working now.
  • 12:43
    The web server is just not running, so it's
  • 12:46
    not going to serve anything.
  • 12:48
    If I redo that command and I type in "start."
  • 12:51
    Then, it'll start the server up again for me.
  • 12:57
    We can go back to the browser and I'll reload again,
  • 13:02
    and now returning again.
  • 13:04
    So, etsy/init.d/Apache to stop, or start, or restart.
  • 13:12
    If you've made some configuration changes, in particular,
  • 13:16
    you would want to restart the server so
  • 13:18
    that your changes would take effect.
  • 13:22
    We've set up the basic LAMP stack, we have phpMyAdmin installed,
  • 13:26
    and we've got some websites going.
  • 13:30
    Everything is set to sort of get going and in the next video,
  • 13:33
    we'll look at how to actually tweak the configuration for Apache, MySQL
  • 13:37
    and PHP.
  • 13:38
    See you next time.

Installing a Web Server on Ubuntu

Loading...

In this video we set up a LAMP stack web server for local development on an Ubuntu desktop (version 11.10). We will walk through installing and using tasksel to get the web server installed, then we'll add phpMyAdmin to the mix. Once we have the server up and running, we'll look at where the web root is and how to add websites. Finally we wrap up with a quick look at how to start, stop, and restart our server when needed.

Next up: Ubuntu Web Server Configuration.