All for Joomla All for Webmasters

Installing a web server on Ubuntu | Apache, MySQL and PHP


In this article, we’re going to be looking at how you can set up your web server for development or play around on Anna Bunty desktop. So we’ll be installing Apache, MySQL, and PHP and this will be on Ubuntu. So before we get actually into anything, I want to find the documentation for this and show you what that is. So it’s on the bunch of sights we go to support and then you can access the free documentation.

documentations ubunru

You’ll notice there are versions here for official documentation, but we’re not going to use those because those would install the individual pieces and we’re going to install all of it in one fell swoop and that you can find in the community documentation. There’s a lot of clicks here, and we’ll put the URL up here at the end so you can just go directly to it. But I want to show you how I got there so in the documentation under software you can look up various applications and then within the applications we’re going to look at servers and web applications.

documentations ubunru1

Then we go down to web servers, and you’ll find a patchy PHP, MySQL the standard lamp stack, and so the final URL here is help.ubuntu.com community Apache, MySQL, PHP and this shows us a very nice simple app.

Some simple commands so that we can install this using tasksel. So this has all of our required documentation and notes that this is for Ubuntu 10.4 and higher versions. So any of the latest versions are going to work with this.

documentations ubunru3

So the first thing we’re going to need to do is to install tasksel. Alright so here’s a command line way to do it and then the second thing we’ll do is install the lamp server using tasksel. So sort of a helper application that will do these kinds of multi-package installations for us. I’m going to show you real quick how you can install task so you can install this through a GUI using your software center. If I search for tasksel in the software here, you can see it’s here, and I can just click the install button chances are if you’re doing this you’re going to need to use the command line. You’re going to have to use the command line to use tasksel itself it doesn’t have a GUI. So I’m not going to install it that way I just want to show you it is there if you feel more comfortable doing that, but you’re going to have to get a little dirty with the command line on this. So I’m going to the command line to install this, and we can look at the move this out of the way. So we can look at the command bits in the instructions here so sudo apt-get this is standard man line installation of something install. Then the name of what I want to install which is tasksel it’s tough to say that without tripping over your words go ahead and put in my sudo password and then hit yes. It’ll take it you know just a few quick minutes here actually to go through the installation process. I returned to my prompt. So now tasksel is installed.

tasksel

That’s step one, and step two is to now actually install the lamp server with our new tool. We just installed so we’ll move this out of the way there’s my second command right, so it’s very similar to the one just ran for apt-get, so this is pseudo tasksel install and then what we want to install from within that tool which is the lamp dash server. So I’m going to go ahead run this installation this one will be a little more involved it’s going to pop up like a little wizard. Ask us a few questions, so it needs to pull down the packages, and as it unpacked them and got them going, it’ll ask us some questions about a configuration that we’ll need to take care of so as we go along we need to set up our MySQL root user. So I’ll just type in a password which you really should remember and ask you to repeat it necessary not to forget your MySQL root user. It’s a pain to have to reset that, and once we get through the installation, so now we should have a web server, and it should be running. So I’m going to go to my browser in a new tab here and write localhost. It is working so the entire lamp stack has installed and the server is running for us. so that’s pretty impressive. I’m going to point out a few other things one is that you should use tasksel to install but not to uninstall or remove. If you want to remove your lamp stack, they have instructions for this all of the individual packages that deleted. You didn’t want to use tasksel you could just manually apt-get install all of those packages. Essentially doing the same thing, it’s just tasksels doing that for you. I want to point out is phpmyadmin that’s a common tool that a lot of people like to use to manage their database. We have to install phpmyadmin which is pretty much what the instructions say. So again this is another application we can go into the software center, and I could install phpmyadmin from here click the install button and install it that’s fine. Since I’ve started on the command line, I’m going to continue that way I just want to show you that with sudo apt-get install for phpmyadmin and it’s going to go ahead, and you know run through the classic. This is also going to ask us for a little bit of configuration information. It needs to know what kind of web server is this phpmyadmin supposed to run with Apache. Since that’s what we’re doing and then I need to configure phpmyadmin, and this is saying unless you know what you’re doing just follow the instructions in the wizard. That’s what we’re going to do yes I do want to follow the wizard here. I need to have a password for the administrative database user. Which we created the last time when we are installing the lamp server, and then that’s the password for MySQL itself password confirmation, so just remember these passwords make sure that you have passwords. You can remember so you can get access to this stuff. Now phpmyadmin is installed. If I go to localhost/phpmyadmin that’s now installed and running, so it doesn’t come with part of the lamp server tasksel installation. But it’s straightforward for you just to add your phpmyadmin. I can manage my database through a GUI. So we’ve all the working pieces in place, but now we need actually to use it.

I have localhost that’s great, but I need what if I want my website files in here so let’s take a look at where stuff is and how to add our web information in here. The location for the server is at VAR then www folder. and you’ll see index dot HTML is the only thing that’s in the folder. When we go to localhost because that is our web root we can also look at the web root in just our regular folders here. I open this up, and we go to the file system because we have to come back out of my user directories we can go to VAR then www that’s the web root, and there’s the index dot HTML file. Now let’s say I wanted to start adding some stuff go in and create a new folder for a new website it’s grayed out and I can’t, I don’t have permission actually to access this. It’s not in my user directory, so we’ll need to take a look at that I’m going to go back to my terminal here, and we’ll look at it from this side so again I can try and make a directory, but I’m getting the permission error. I’m making a list all here, and you can see that the www directory is owned by root because root installed. We’re doing all the pseudos you need route 22 and do all these installations, but now my web root is also controlled by the root user, not by my user. I have to use sudo to do everything, or I can change the ownership of just my web root to my owner which in this case my account which happens to be parallels. Now you can see I did a chown just on the web root folder to my account so don’t have to keep doing sudo and deal with all the permissions problems that are a personal choice for you. It’s my local, so I’m not too worried about a ton of security around my web root. So if I go back in here now to my web root, you’ll see that I can now make a directory and I don’t get permission denied. We can go back over here also to my file browser right and in the GUI, and you can see that I created the folder and I can get access to it and now I can create new folders and documents. So I’m going to create a new document for my new website called my site just index.html could be index dot PHP you know whatever put your CMS files in here. I’m going put HTML a new I just want to test to make sure this is working so I’m just going to put some text in here, so you know this is my new development site. waahoo exciting I’ll save this file, and we can go ahead and just close this out. So again I’m in VAR www my site folder inside of my web root, so I’m going to go back to the browser and test this so localhost is Webroot www my site folder within it and my index HTML is displaying, so that’s cool. I have a website so now that I have this working and I can put up many dev sites. I don’t really need this index HTML in my main web root because just showing a message that doesn’t need.

So I can go ahead, and I’ll just move this off to the trash I could put a website directly on the route, but for development, you often have many sites. I removed the index HTML in the www folder and so now when I go back to localhost I don’t get that text that was displaying. but I can see a listing of all the folders that are in that directory. Which would be all my development sites I’m working on and then I can just click on the one that I need so we have a web server installed and running. We know where to put our files so that we can start creating development sites within that. So the last thing that we need to do is see how we can turn the server on and off because it was turned on for us by default but what if you want to turn it on or off or restart it. It’s here you could search anywhere on the web to find the command for turning the server on and off. But I know it’s on this one page of documentation which is handy. The commands for restarting you can also use that to stop it and start it individually without restart. I’m going to go ahead and type that in terminal it’s sudo /etc/init.d/apache2 stop to stop it, so I’ve now stopped it. If I go back to the browser here and I reload this page go up here just you know every load, it’s not working now. So the web servers just not running so it’s not going to serve anything. If I redo that command and enter start at the end of previous command, then it’ll initiate the server up again for me. We go back to the browser, and I’ll reload again, and now it’s running again. Let’s see init.d Apache to stop or start or restart if you just want to reset if you’ve made some configuration changes in particular. You would want to restart this server so that your changes would take effect. We’ve set up the lamp stack we have phpmyadmin installed, and got some websites going so everything is going well.


Like it? Share with your friends!

0
, 0 points

Installing a web server on Ubuntu | Apache, MySQL and PHP

log in

Become a part of our community!

reset password

Back to
log in
Choose A Format
Personality quiz
Trivia quiz
Poll
Story
List
Meme
Video
Audio
Image