How to set up LAMP on Ubuntu Desktop Edition
So I’m now using my second laptop as a Linux dev server. Ubuntu is what all the cool kids are using so I thought I’d give it a go. Wait a minute, oh crap, I have to make a choice between Ubuntu Desktop Edition and Ubuntu Server Edition. Well I want to use it as a LAMP server but at the same time I want a desktop and all that comes with it. I figured I’d be able to download the Desktop Edition and sort it out later. I am happy to report I was correct, but I learned a little on the way. Here’s how you do it.
First off I downloaded and installed Ubuntu Desktop Edition. That went very smoothly, however I was a little concerned that although I created a user account during installation I wasn’t asked to specify a root password. All became clear after I discovered that they use sudo instead - in fact there is actually no root account by default.
This is also the first time I’ve used a Debian based distribution. Only now can I see why people have been banging on about apt-get and how slick it is.
sudo apt-get install apache2
As simple as that. Done. Apache 2 is now installed and ready to use. Amazing.
sudo apt-get install php5
sudo /etc/init.d/apache2 restart
Same for php5. Wow.
sudo apt-get install mysql-server
sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysql
sudo apt-get install phpmyadmin
You get the picture…
I just had to edit php.ini to enable the extension.
gksudo gedit /etc/php5/apache2/php.ini
extension=mysql.so
Restart Apache again and I’m done.
My gob is still smacked.
I’m still adjusting to this whole no root account business, but at first glance Ubuntu gets the thumbs up from me.
See my follow-up post here.

Wael wrote,
Hey
Should I be connected to the internet in order to do the “sudo apt-get install” thing?
Appreciate your help
Thank You
Link | May 10th, 2007 at 8:03 pm
Neil wrote,
Hi Wael
Yes you normally need to be connected to the internet in order to use apt-get, unless you specify other sources - e.g. a local network or a CD/DVD.
Basically apt-get is a front end for the Ubuntu (Debian) package manager (dpkg). You tell it to install/upgrade/remove packages and it works out from where, how to do it, and in which order they need to be done in - all automatically. If you’re interested there’s more information on apt-get here.
Hope that helps.
Link | May 11th, 2007 at 9:55 am
Wael wrote,
Hello again,
Appreciate your help
What if am not connected to the internet and I want to set up Apache, MySQL & PHP.
Shouldn’t they be present in my Ubuntu Desktop Edition CD?
Link | May 11th, 2007 at 9:24 pm
Neil wrote,
Ah good question, I see what you are asking now. I have just taken a look at my software sources and it seems to me that Apache, PHP and MySQL are not present on the Ubuntu Desktop Edition CD. When I used apt-get to install them it must have downloaded them from the online ubuntu archive via the internet.
Since the desktop edition is only one CD it makes sense that the compromise on space would be server related.
Is there no way you can get internet access for your computer; at least just for the period of time you need to install Apache, PHP and MySQL on it?
Link | May 12th, 2007 at 7:43 am
Wael wrote,
Ya I’ll try and do that
Thank you
Link | May 13th, 2007 at 2:46 pm
Ghryswald wrote,
Thanks for posting the info.
I installed the server edition, only to find myself staring at a command-line prompt, scratching my head. I shrugged and went the opposite direction, installed desktop edition on top of it, only to watch error after error scroll along. {flush and restart}
Found your page, and it looks like everything crawled along just fine. Had some issues with my vid card (Inspiron 1100) which other pages walked me through sufficiently.
I’ve been trying to get a Bugzilla installation going on a Dell desktop using Fedora Core 6, but was having no luck at all. So, I’m giving Ubuntu a go on the laptop, and if that works, will go with Ubuntu on the desktop as well.
Again, thanks for the easy walkthrough.
Link | July 9th, 2007 at 12:22 am
tamal wrote,
I guess if we could download XAMPP for Linux (http://www.apachefriends.org/en/xampp-linux.html) then we can install entire LAMP package over Ubuntu DE. I’ve yet to try this though.
Link | July 11th, 2007 at 8:33 pm
Petter wrote,
Hi, I guess I’m quite a newbie when it comes to linux in general. But, I followed your lead and everything went smoothly. Thanks for that. I have a question though, how can I create and manage my “Lamp files” (those that are located where apache was installed) using the desktop edition, when I’m not logged in as root?
Hope I made myself clear, thanks.
Link | July 23rd, 2007 at 1:39 am
Neil wrote,
Hi Petter
Are you talking about editing the configuration files? If so then as above. Open a shell (e.g. Applications > Accessories > Terminal) and for example type in:-
gksudo gedit /etc/php5/apache2/php.iniYou will be asked for your password and then you will be editing that file as ‘root’.
If you simply want to open a ‘root’ session then I use:-
sudo -iYou will be asked for your password and then everything you do from then on will be as ‘root’ - you can easily tell this from the ‘root@…’ prompt. From here I tend to use the text editor ‘nano’ like so:-
nano -w /etc/apache2/sites-available/defaultAlthough you can still use gedit or the like if you prefer (although without needing gksudo to begin with). When you have finished with root you type:-
exitAnd you’re back as your normal user. For more info on using sudo see https://help.ubuntu.com/community/RootSudo.
Hope this helps. If not please get back to me and let me know in more detail what you mean as I may even dedicate a follow up post on this to explain in more detail.
Link | July 23rd, 2007 at 8:24 am
Petter wrote,
Hi again.
That was sort of what I was looking for, but I want to be able to edit my files right there on the desktop. Without using any terminal. Like logging on as root on the desktop edition. This is mostly because I’m not used to using the terminal in any way.
Thanks.
Link | July 23rd, 2007 at 11:48 am
John Lubotsky wrote,
Neil: Like you, my jaw is on the floor. I had no idea it could be this easy to setup.
What I’d love to know now is: how did you come up with this particular list of packages to install? And how did you find out about mysql.so?
Regards and thanks,
John
Link | July 25th, 2007 at 8:22 pm
Neil wrote,
@Petter - As mentioned above, yes it’s using a terminal to begin with but if you use the
gksudo geditoption alone that will open a graphical editor (gedit) with root priveledges. Then you can use that to edit any number of files you fancy. You could start by clicking on ‘Open’ and entering in the ‘Location:’ field ‘/’ (without the apostrophes) and hitting return. Doing this is a little like looking at ‘C:’ on Windows, it will show you all the directories and files available for you to browse and edit on your system.If you are talking about perhaps constantly running as root (a bit like running with an admin account in Windows) then you could follow this tutorial, but I personally do not recommend this. However, if you do feel that this would be preferable then may I suggest after you have created the root login possibility, perhaps just login as root, perform your tasks, and then logout and log back in as a normal user. It really would be better to avoid being logged in as root for surfing, email and all the other day to day stuff.
@John - I came up with this particular package list because that is what makes LAMP (Linux, Apache, MySQL and PHP). I use these things for my website hosting, as do many others. The precise packages were, for me, the bare minimum I needed to use MySQL with PHP. I would have had to install similar packages when doing it on Redhat using rpms. I didn’t include perl, python, etc. but they could also be added in a similar way. Search the Ubuntu packages archive (Feisty) for packages available, or use
apt-cache searchto search for packages available.As for the mysql.so: well it didn’t work initially, but since I have some considerable experience with Linux from using it on and off for the last 8 years for both hobby and work I knew it had to be loaded. I looked into the php.ini file to uncomment it and found that it wasn’t even there at all. I added it and voila it worked. Sorry I can’t be more logical than that, but there are just some things you get to know. I recommend keeping a log book with all these things written in. I refer to mine all the time.
Link | July 26th, 2007 at 6:21 am
Petter wrote,
Thanks, but I’ve already worked it out
Link | July 27th, 2007 at 4:23 pm
zaphu wrote,
Well done! — very simple instructions.
Link | August 7th, 2007 at 10:57 pm
Chris wrote,
I just install 7.04 Desktop and there is no listing for apache2 in any of the pkg managers. aptitude search apache2 gives nothing.
C
Link | August 23rd, 2007 at 11:06 pm
Neil wrote,
Hi Chris
I just tried it and it works OK for me.
sudo -iapt-get update
apt-cache search apache2
That spews out a long list of packages, along with apache2 itself.
Perhaps try again and let me know?
Link | August 25th, 2007 at 8:28 am
Alan wrote,
Hi Neil,
You’re very modest. I don’t find a lot of people like you on the web. Not only are you experienced and know what you are talking about, but you are humble too. You take what you know and you make it very easy for others to do what would otherwise be a very complicated task. When people ask questions which perhaps would be very obvious or very simple to you, you answer with respect and understanding and clarity.
Very unusual. We could do with more people like you. Kudos.
Alan
Link | October 14th, 2007 at 5:05 pm
ben wrote,
what can I say?
THANKS!!!
I have tried various permutations of the desktop / lamp install, and ran aground a few times. I have had an Ubuntu install on my laptop since dapper, but only tried for a lamp install since feisty.
Going for an all singing all dancing ubuntu (lots of ubuntu-studio apps / compiz&emerald /games /wi-fi / etc etc) and having a test server running for my textpattern experiments was never so easy as you have just made it with this post
my ghast is completely flabbered dude
you make escaping/avoiding MS a joy!
Link | March 11th, 2008 at 10:51 am
Paul Riter wrote,
I appreciate this, but I’ve hit a snag. When I try to do the apt-get for phpmyadmin I get the following message:
E: Couldn’t find package phpmyadmin
Please note that while I am a professional programmer, I have minimal experience with Linux.
Link | March 24th, 2008 at 7:02 am
Neil wrote,
Hi Paul
I’ve just searched around and found that for some reason some people haven’t got the ‘universe’ repository enabled in their apt source list (where the apt package manager ‘looks’ for its packages to install).
This list is located here:-
/etc/apt/sources.listJust make sure the ‘universe’ repositories are uncommented (remove the ##).
Here is the thread I found the information in:-
http://ubuntuforums.org/showthread.php?t=202810
And here’s the specific post with the howto within that thread:-
http://ubuntuforums.org/showpost.php?p=1187120&postcount=4
Hope that helps.
Link | March 24th, 2008 at 12:10 pm
Mikkel wrote,
Thank you very much for the tutorial but I have one (maybe two) questions..
Trying to restart my apache2 server
sudo /etc/init.d/apache2 restart
And I get this alert
apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
What does it mean and can I do anything to resolve this alert.
Link | April 17th, 2008 at 10:30 am
Neil wrote,
Hi Mikkel
Assuming you are just using this as a test server at home rather than as a live real server which would need a fully qualified server name, you can simply do this:-
gksudo gedit /etc/apache2/httpd.confThen add the line:-
ServerName localhostAnd then save it.
Now restart apache:-
sudo /etc/init.d/apache2 restartThe message should no longer appear.
Link | April 18th, 2008 at 8:45 am
Mikkel wrote,
Thank you very much. It helped and the server now works
I have just one more question. Where do I place my index file so that this runs in the server. I want the page to be available on all LAN computers. Like a internal homepage which only can be reached when the computer is connected to the LAN
Link | April 20th, 2008 at 9:20 am
Neil wrote,
By default I think the files are stored in /var/www/
However if you edit /etc/apache2/sites-available/default you can change the ‘DocumentRoot’ to whatever you like. I have mine set to /home/neil/webpages/current-site/ where ‘current-site’ is the directory where the current site I’m developing is located.
gksudo gedit /etc/apache2/sites-available/defaultDocumentRoot /your/document/root/dir/here/
Note the trailing slash is required at the end of the DocumentRoot path.
Also you’ll need to scroll down and alter the
< Directory /var/www/ >setting to, for example,< Directory /home/mikkel/ >and make sure the RedirectMatch apache2-default has a # in front of it.Of course you change DocumentRoot to whatever you want it to be. The # in front of any config line essentially comments it out.
If you do change the DocumentRoot to something convenient like a directory within your home directory make sure you alter the permissions on it to allow Apache to use it. For example:-
sudo chmod -R 644 /home/mikkel/webpagesThat should do it, although you may have to lighten up the permissions for some web applications, but that should get your started.
I think that’s all there is to it. The problem is I’ve changed so many of my config files to suit my particular needs that I haven’t got a default system anymore. I may have overlooked something, so do let me know if it works for you, and if not, what errors you get.
Of course you will need to restart apache in the usual way after making these changes.
Link | April 20th, 2008 at 3:19 pm
Mikkel wrote,
It worked with the localhost edit. I now don’t get the error message.
I have decided not to change the default DocumentRoot however I can’t get the server to work 100%.
http://img142.imageshack.us/img142/4070/screenshot5nb0.png
I get this message when trying to edit the default index and when I try delete the default edit and replace it with my own index test file I get the same error. Can you help me with this.. ?
And finally one more small question. When the server is hosting the index.html how can I access this file from the other LAN computers. What can I type in into the browser to open the webpage.?
Link | April 22nd, 2008 at 6:28 am
Neil wrote,
That error is because you do not have the permission to alter the file. Instead you can open it using gksudo like this:-
gksudo gedit /var/www/apache2-default/index.htmlYou need to know the IP address of your Ubuntu server in order to access it from other computers on your LAN. Do this:-
ifconfigThe second line down will show you the ‘inet addr’ which in my case is
192.168.1.8.So now simply use one of the browsers on your network like so:-
http://192.168.1.8/Hope that helps.
Link | April 22nd, 2008 at 9:21 am
Mikkel wrote,
Thanks. It helped and I now have a fully functional site.
Link | April 25th, 2008 at 8:30 am
Cameron wrote,
Thanks!
Only one question, how do i access phpmyadmin?
Link | May 7th, 2008 at 9:21 pm
Neil wrote,
Hi Cameron
Try http://your-server-url-or-ip-here/phpmyadmin/
I have looked and can’t recall if I added it myself or if it was there by default, but in
/etc/apache2/conf.d/phpmyadmin.confthere is an alias set up for it like so:-Alias /phpmyadmin /usr/share/phpmyadminAdd the above code to the top of that file if it is not there already and it should work.
Link | May 8th, 2008 at 8:10 am
Cameron wrote,
/etc/apache2/conf.d/phpmyadmin.conf wasnt present
Link | May 8th, 2008 at 3:34 pm
Neil wrote,
OK, looks like the symbolic link is missing for some reason, try this:-
sudo -iln -s ../../phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
Then restart apache:-
/etc/init.d/apache2 restartNow it should work, let me know.
Link | May 8th, 2008 at 4:21 pm
Cameron wrote,
Yes that has worked, thanks for all your help
Link | May 8th, 2008 at 5:39 pm
Derrick wrote,
Fantastic. Ridiculously easy to follow. Thank you!
Link | May 9th, 2008 at 7:16 pm
Omar wrote,
Neil,
Thank you for the simple explanations so far. I have one question. I followed your instructions for installing LAMP on my laptop and everything works great so far. However, when I move my zenCart files to /var/www/ get a permissions error. I am a serious newbie to the LINUX world. I tried changing permissions on the source and destination folders and still am unsuccessful.
Link | May 13th, 2008 at 8:48 pm
Neil wrote,
Hi Omar
I don’t know anything about Zen Cart software and the permissions it requires, however I found this and it appears to give the answers:-
http://tutorials.zen-cart.com/index.php?article=9
Link | May 13th, 2008 at 9:39 pm
Omar wrote,
Thank you very much for your input.
Link | May 14th, 2008 at 11:12 pm
Ben wrote,
Fun fact. sudo passwd root that will ask for your password, then ask you to specify a new unix password… for root! thus enabling root shell logins
Link | May 21st, 2008 at 7:31 am
Neil wrote,
Nice one Ben, one to remember for next time I asked.
Link | May 21st, 2008 at 8:32 am
ben wrote,
It won’t allow a GUI login though, you have to change some settings elsewhere for that.
Link | May 21st, 2008 at 9:59 pm
Follow up on my Ubuntu LAMP how to wrote,
[...] it’s been over a year since I wrote ‘How to set up LAMP on Ubuntu Desktop Edition‘. Has anything changed? Is there anything to add? Let’s find out [...]
Link | June 6th, 2008 at 10:26 am
Using your Ubuntu Apache test server with Windows wrote,
[...] we’ve set up our Ubuntu LAMP server, but now we want to use it to develop our wonderful websites via our Windows desktop machine, here’s how [...]
Link | June 6th, 2008 at 2:25 pm