Your Ad Here

Ubuntu LAMP Server - Setup Guide with Desktop GUI

Ubuntu LogoUbuntu (for those of you who have been living under a rock) is fast becoming the free Linux distribution of choice for home computing. Dell has even begun to ship machines with Ubuntu pre-loaded instead of Windows or Red Hat. But Ubuntu is not just for desktops. It’s also available as a super easy to install “Server Edition” that comes complete with DNS server and LAMP (Linux, Apache, MySQL, PHP) server components. Unfortunately, the “Server Edition” does not install with the pretty GUI and the bells and whistles (like OpenOffice and Firefox) that come standard with the “Desktop Edition”. But you can have the best of both worlds. Here is how you set up a Ubuntu LAMP server on your local area network and customized the installation to include the Ubuntu Desktop GUI.



Step 1: Install Ubuntu Server Edition with LAMP server components.

Download the disk image (*iso) for Ubuntu Server Edition (currently version 8.04 Hardy Heron) and burn it to a CD. Ensure that your BIOS is configured to boot from the CD-ROM drive. Restart with the Ubuntu disk in the drive and the machine should boot into the Ubuntu installation shell. If you would like to configure a static IP address, select F6 - Other Options and enter

netcfg/disable_dhcp=true

at the end of the options string, and the install script will prompt you for network information during the installation. Otherwise, the static IP must be configured post installation as per the second part of step 2 below, and your network will be automatically configured using DHCP (as long as DHCP is enabled on your router). In either scenario, you must enter a hostname when prompted.
As you work through the installation (most of which is self explanatory), you will also be prompted to select a partitioning method. The most straightforward method is “use entire disk”, which will format a drive of your choice before installing system files to it. Finally, you will be prompted to enter a full name and a short name for a non-administrator account (separate from root). After a few more trivial questions (like “What is your time zone?”), and a plethora of file copying, the install shell will ask you to select optional software to install. Select LAMP (using the arrow keys and spacebar). If you wish to install a name server as well, you may select DNS and follow the instructions of this post. You may also elect to install an OpenSSH server at this point and bypass the first component of step 3 below. After making selections, continue the installation by pressing enter. At some point, you will be prompted to enter a mysql root user password. If you wish, this password can be left blank for now.

Step 2: Enable root access and configure a static IP address.

After installation finishes and the system reboots, log in using the non-administrator account created during installation. (Note: my system hung after reboot and I had to press enter to get the login prompt.) The first thing you will probably want to do once you log in is set the root password (by default the password is left blank). To do so, type the following at the command prompt.

sudo passwd root

Since you are planning to use the machine as a web server, you will also need to specify a static IP address (if not already configured during the installation). To do so, you must edit the interfaces configuration file (use your favorite text editor; I use vi here).

sudo vi /etc/network/interfaces

If DHCP was enabled during installation, a chunk of this file should look like the following:

auto eth0
iface eth0 inet dhcp

Change dhcp to static and add the lines shown below. Of course you need to use your IP address, netmask, and gateway instead of mine.

auto eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

You also need to specify the DNS server(s) in the resolv.conf file.

sudo vi /etc/resolv.conf

Replace the xxx.xxx.xxx.xxx in the nameserver xxx.xxx.xxx.xxx line with the address of your DNS server. You can add multiple DNS servers if you like by duplicating this line using other DNS server addresses. Now restart your network components.

sudo /etc/init.d/networking restart

Ping www.zaphu.com (or some weblog of lesser quality) to make sure your network configuration is working.

Step 3: Install OpenSSH and Ubuntu Desktop components.

If you didn’t do so during the installation, you will probably want to install an SSH server at this point so you can login to your new LAMP server from other machines on your local area network. Installing packages is a snap with Ubuntu using the built in aptitude package management software. The first step is to update the packages database by typing

sudo aptitude update

Then install the openssh-server package.

sudo aptitude install openssh-server

You need to insert the Ubuntu Server installation disk to complete the installation. Installation of the Ubuntu desktop environment (and all of the goodies that go with it) is also a snap using aptitude. Type

sudo aptitude update
sudo aptitude install ubuntu-desktop

Because a significant number of files need to be downloaded, the Ubuntu GUI installation may take some time. Near the middle of the installation you will be asked to configure the Postfix mail transfer agent. Since my machine is not going to be a mail server I selected ‘no configuration’ and continued, but you may want to configure Postfix differently. Check out Ubuntu Forums for information on configuring Postfix. When the Ubuntu desktop installation finishes, fire up the GUI.

sudo /etc/init.d/gdm start

Congratulations, you now have a fully operational Ubuntu LAMP server with the niceties of the Ubuntu desktop environment. In a follow-up post, I walk you through the setup of a website on your new server and the installation of phpMyAdmin to help manage all of those mySQL databases you will be creating.

If this guide leaves you scratching your head, check out the related posts on these weblogs: Debian Admin, spoffle

If you liked this guide, show support by leaving comments and visiting our sponsors.



Update, Aug. 13, 2007: Dell has announced that they will start to ship Ubuntu-equipped machines internationally. Perhaps Microsoft’s days are numbered. Read about it here.

Update, Aug. 23, 2007: Here is a first hand account of a Ubuntu Dell by someone who bought one.

Update, Aug. 30, 2007: The next version (8.04) of Ubuntu (Hardy Heron) has been announced for release in Q2 2008.

Update, Oct. 24, 2007: Ubuntu 7.10 has been released and is receiving great reviews.

Update, Apr. 27, 2008: I updated this post for Ubuntu 8.04 Hardy Heron.


56 Comment(s) rss

  1. Well done, I’m impressed.

    John | Aug 7, 2007 | Reply

  2. Thank you !!

    I’m new to Linux and Ubuntu and this is the only guide I’ve found that actually works.

    Cheers :-)

    Magnus | Aug 29, 2007 | Reply

  3. @Magnus - Thanks for the vote of confidence. As always, let me know if something is missing that might improve the post.

    Sam | Aug 29, 2007 | Reply

  4. Thank you Sam!

    Just what I’ve been looking for. :)
    Keep up the good work!

    Sincerely,
    Peter

    Peter | Aug 31, 2007 | Reply

  5. I am new to Ubuntu and this guide made it really easy to get started.

    Thank you very much!

    Karl | Sep 4, 2007 | Reply

  6. @Peter, @Karl - I am glad I could help. You might be interested in this other post that gives you some pointers on setting up your server to wake-on-LAN. This feature is a really convenient addition to my LAMP server.

    Sam | Sep 4, 2007 | Reply

  7. Really great guide, concise and clear, did exactly what I needed done.

    One suggestion I would just leave out the IP stuff at the beginning, a true linux noob like myself will just be scratching their head like a dumb monkey when vi editor pops up. Once we have the GUI up and running changing the IP to static is a snap from the desktop.

    Thanks much again.

    Steven

    Steven | Sep 20, 2007 | Reply

  8. @Steven - Thanks, there is also a way to configure a static IP address during installation instead of accepting the default install options that use DHCP to configure your internet connection. When the install shell boots from the CD press f9 (Other Options) to specify additional install options. Add the following to the end of the option string: netcfg/disable_dhcp=true Now the install script will prompt you for your IP address etc. during installation.

    Sam | Sep 20, 2007 | Reply

  9. Thank-you kindly, nicely done, straight forward and bitesized for the newly initiated.

    Cheers,

    Gary

    Gary | Sep 21, 2007 | Reply

  10. sorry but i’m really a newbie here at LINUX UBUNTU how can i install the GUI of UBUNTU because i have tried the codes above but the error is it could’nt find ubuntu-desktop package, and how can i connect in internet using dial-up?
    Tnx for advance…

    raymond | Sep 25, 2007 | Reply

  11. @raymond - If you are using dial-up, I would recommend installing the desktop version of Ubuntu first (instead of the server version used here) and using the GUI to configure your dial-up preferences (see here). After this is complete, you can use the aptitude package management software to install the LAMP server components (see here).

    Sam | Sep 26, 2007 | Reply

  12. Concise, easy to follow, really good stuff, and much appreciated. Cheers

    Graeme | Sep 28, 2007 | Reply

  13. MANY thanks! This is FANTASTIC!!!!!

    HOWEVER: There is ONE issue that stopped me cold. It kept asking to put CD in and even though it WAS in, would keep requesting. Infinite loop!

    I had to go in and comment the CDROM line out: Problem solved!

    I downloaded all the files through the NET and was sure glad I have a fast connection!

    I’ve wanted to do this for a LONG time! Again, THANKS!

    MKS4FUN | Sep 30, 2007 | Reply

  14. Opps! Here is the ‘fix’ I forgot to post:

    You have to comment out the cdrom reference in /etc/apt/sources.list

    Top of the file, just under the one that is already commented out. Add the # symbol like above.

    Good Luck!

    MKS4FUN | Sep 30, 2007 | Reply

  15. Everybody told me I was too old to learn something as complex as Unix. OK, I’m 84 but I’m a stubborn oldtimer .. and the more they told me I couldn’t do it the more determined I became.
    I could not have done it without your excellent guide - it made everything clear and I had no trouble getting a final ‘thumbs up’! Thanks for making me feel young again!

    Tom | Oct 10, 2007 | Reply

  16. THANKS A LOT

    any other way to install ubuntu-sesktop for an ubuntu server using the dpkg

    THANKS AGAIN

    Supertunisian | Oct 10, 2007 | Reply

  17. @Supertunisian - The aptitude package management software that is integrated with Ubuntu is actually an implementation of the Debian package management system (dpkg).

    Sam | Oct 11, 2007 | Reply

  18. I cann’t change the password for the root.

    marcin@webserv:~$ sudo passwd root
    marcin is not in the sudoers file. This incident will be reported.
    marcin@webserv:~$ sendmail: fatal: open /etc/postfix/main.cf: No such file or directory

    Macin | Nov 20, 2007 | Reply

  19. @Macin - You need to be sure your account has administrator privileges. If marcin is a limited user the sudo command will not work. The account created during installation is by default granted administrative privileges.

    Sam | Nov 20, 2007 | Reply

  20. Thanx for this guide ,i was looking for something like that and i am also a newbie and excuse me if my question seem to you stupid :P

    if i dont set a static ip and i have created a site that i want to show to my friends…how can they access it??? by giving them my IP address at that time???

    thank u for ur time

    St0iK | Nov 21, 2007 | Reply

  21. @Stoik - Even if you have a dynamic IP address, you should be able to view your site if you enter the currently assigned address in your browser. Of course, if you are hosting on a local area network, only machines that are also on that network will be able to view your site. Machines on the wide area network will not be able to view your site unless you tunnel through your router. This can be quite difficult to do.

    Sam | Nov 24, 2007 | Reply

  22. Hi -

    My mom just got me a Dell computer with Ubuntu at the start of the school year. It worked fine until I upgraded to Ubantu 7.10 Gusty Gibbon. The GNOME didn’t work - the Dell help desk was ok. Then the sound wouldn’t work. Agin the dell help desk talked me through the steps to get the sound working.
    Now I can’t record sounds, and the USB port won’t recognize any external hard drives. It still recognizes printers, but not external thumb drives or or hard drives.
    Dell reccommends re-installing 7.4 Fiesty Fawn, but says I will lose all my work.

    How can I do a nondestructive re-install of 7.4? Or how can I fix the recording drivers and the USB port?

    Thanks -

    Ian Warner-O’Connor

    Ian Warner-O'Connor | Dec 3, 2007 | Reply

  23. @Ian Warner-O’Conner - You seem to be having a lot of problems. I would recommend trying to fix the flaws with 7.10 before reverting to 7.04. Try this page for some help with 7.10 on Dells. Also take a look at this page, which is Dell’s Ubuntu 7.10 upgrade blog. I don’t think I can be of much additional help on this problem. Good luck.

    Sam | Dec 4, 2007 | Reply

  24. Thanks for the guide!! This has set me on the path to be able to learn how to use this system - else I would be stuck on the command prompt still ….

    Tim Scale | Jan 6, 2008 | Reply

  25. @Tim Scale - Thanks for the support

    Sam | Jan 8, 2008 | Reply

  26. Great post - a huge help. Can’t wait to read your “website setup” post!

    Zach | Jan 15, 2008 | Reply

  27. Thanks for the guide. It took a few tries, but everything appears to be working OK now.

    FWIW, when I ran through the process the first several times I was using an X2 4400+ on a DFI Expert board and an Nvidia 7800 GT. Everything worked perfectly right up until I went to launch the desktop–I’d get no video, scrambled video, or some other garbage. I swapped out the X2 and used an E6400 on an Asus P5B-D with the Nvidia 7800 GT and got basically the same result. I then swapped out the 7800 GT with an ATI 1950XT and when I launched the GUI it worked.

    I have no idea why it didn’t like the previous hardware, and for all I know it would have worked fine with the X2 4400+ and the ATI video card (I do have another 1950XT so I’m going to set it up with the X2 4400+ in another machine; but not today!). I did put the 7800 into a Windows machine and it worked fine, so….

    MarcoVincenzo | Jan 21, 2008 | Reply

  28. Sam,

    Your clear and precise instructions to get both the worlds on Ubuntu (Desktop & Server), helped me a lot, when I am scratching my head.

    Keep-up good work!

    Thanks Again - Vijay

    Vijay | Jan 22, 2008 | Reply

  29. Sam,

    Great guide!!! I tried a few others (which didnt work) before I stumbled on to yours, which worked great!

    I’m a bit of a noob when it comes to linux! So if you dont mind I’ve got one question… I cant seem to get the static IP set up. What address do I put in the nameserver line?

    Thanks!

    Mike | Jan 23, 2008 | Reply

  30. @Mike,Vijay - Thanks for the support.
    @Mike - The nameserver IP address is the address of your DNS (domain name system) server. If your ISP uses DHCP then you should be able to view this address on your router’s configuration page. If not, then check with your ISP for this address. Subscribe to our RSS feed and visit again soon.

    Sam | Jan 23, 2008 | Reply

  31. I just want to say thank you for a well defined guide. I have passed this to many a friends. Seriously thanks.

    Micheal | Feb 2, 2008 | Reply

  32. WOW! just WOW!

    this has been a huge help!

    I have only had one problem: when I go to run the GUI i get a BASH error talking about how DMX dosent exist (and its true its not in the folder it should be) what can i do to reinstall the aptitude package corectly???

    Thanks again

    Ben

    B-man | Feb 3, 2008 | Reply

  33. thank u… It would be more helpful if there comes up another such guide for fedora LAMP… plz post that too

    shri | Feb 11, 2008 | Reply

  34. @B-man - I am not familiar with DMX. Google indicates that it is a package to control lighting devices. Do you have some PCI card that is used for such a function?

    Sam | Feb 14, 2008 | Reply

  35. This is brilliantly done!
    Thank you so much for your help.

    Blair | Feb 18, 2008 | Reply

  36. Hello,

    I’d like to first say that this tutorial is very helpful. To begin with I followed the tutorial for Ubuntu 7.1 Desktop version to be installed on Virtual PC. However, I wanted to swap to the Server version for the pure reason that the LAMP install would be simpler relative to the Desktop. Thus, also placing this onto Virtual PC 2007 (host is XP pro), I bypassed Step 1 and 2 for the moment and got to Step 3. Everything went fine (as far as I understand) until launching the GUI. Upon startup of the GUI, the resolution is scrambled, similar to what happened with the Desktop version. With the Desktop version, this issue is resolved by hitting F4 to select the lowest resolution. I attempted the same action with the Server to no avail. Does anyone have some suggestions? And please keep in my mind that I used these great tutorials as my only knowledge base. :)

    Thanks in advance!

    MjrNut | Feb 22, 2008 | Reply

  37. Update

    So far I have resolved the GUI resolution problem with the following:

    edited the xorg.conf file
    DefaultDepth from “24″ to “16″

    This did the trick and made boot up to the Desktop Gui in the Server edition successful.

    MjrNut | Feb 22, 2008 | Reply

  38. @MjrNut - Thanks for posting the information on the GUI resolution fix.
    @Blair - Thanks for the support.

    Sam | Mar 18, 2008 | Reply

  39. Hi everyone!

    I already installed Ubuntu 7.10 Desktop Edition and now I want to install LAMP. How? Is there a straightforward way to install LAMP so that I will no longer install Apache, MySQL and PHP one by one? Please help…. Thank you very much.

    Regards,
    Jess

    JessMagz | Apr 10, 2008 | Reply

  40. @JessMagz - If you did not install Apache, MySQL, and PHP during the Ubuntu installation then the easiest thing to do is to install these packages piecewise following a tutorial like this one. Good luck.

    Sam | Apr 15, 2008 | Reply

  41. Top quality !

    I’m new to LINE-UX and really needed the GUI to get me into it. I’ve set it up so I can test my php apps. This guide was a blessing.

    Dave | Apr 16, 2008 | Reply

  42. Hi,

    i have commented that cd from sources, it works. Thanks for posting that :-)

    Regards,
    Sheshu.

    Sheshu | Apr 18, 2008 | Reply

  43. I’m puzzled by the IP numbers.
    In your you example:

    address 192.168.1.10
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1

    The details I have are described as

    IP Address range
    DHCP Address range
    Subnet Mask
    Gateway/Router IP Address
    DNS Server addresses (2)

    Wondering what I use for broadcast and network ?

    regards,

    geoff

    geoff | Apr 20, 2008 | Reply

  44. @geoff - If you are configuring a static IP address on your machine, just delete everything in the /etc/network/interfaces file and replace it as per what is in this post.

    Sam | Apr 21, 2008 | Reply

  45. Sam, Thanks for that. I’m now able to create a ‘hello world’ html program from the server and view on a connected machine, However I’m trying to run php and have followed the procedure in your follow up post and have set up a cgi-bin directory. Im getting errors, in the apache log file it says exec format error : exec of ‘/home/geoff/public_html/cgi-bin/index.php’ failed.
    I’ve set up:
    AddHandler cgi-script cgi pl php
    which I guess i need? Is this the way to get php scripts to run?
    I also tried putting my hello world html file in the cgi-bin directory and I get an error when trying to read it from another machine. I’ve tried to chmod the files in case thats the problem. Checked everything in your post several times. Still no php. I think my php script is OK.

    regards,

    geoff

    geoff | Apr 22, 2008 | Reply

  46. Way to go Tom, keep it up and remember…. Have Fun. :-)

    Dave | Apr 25, 2008 | Reply

  47. I’ve now loaded 8.04 Desktop. I then installed php and apache2, following your guidelines.
    All now works!
    Next step, how do I get the world on the other side of my router to run my php pages?

    geoff

    geoff | Apr 26, 2008 | Reply

  48. @geoff - I will check my post instructions and see if I can get a PHP script on Hardy Heron (8.04) to run. I will get back to you.

    Sam | Apr 27, 2008 | Reply

  49. hi! thanks for the step by step tutorial, im new to linux and your site help me a lot!

    keep up the good work

    zedd | Apr 30, 2008 | Reply

  50. What a wonderful website! Your instructions were very easy to follow and I am falling more and more in love with Linux (Ubuntu) by the hour. I can’t wait to see what else I can do!

    Rodd | Jun 4, 2008 | Reply

  51. @zedd, Rod - Thanks for the support. I just posted some new Ubuntu guides. Use the search box and keyword “Ubuntu Guide” to find them or go to our Ubuntu category. Subscribe to our RSS feed too.

    Sam | Jun 4, 2008 | Reply

  52. Huge thanks Sam - this was perfect and worked without any errors at all. My only problem being a newbie to Linux was understanding HOW to use VI. Thankfully Google didn’t let me down! Great post.

    Regards,

    Alan

    Alan Barber | Jun 8, 2008 | Reply

  53. I too am a linux newbie and found this useful. However, it may be useful to describe how long each installation step may take. Installing the gui on my side took quit a while.

    Sean | Jun 8, 2008 | Reply

  54. I have installed Ubuntu 8.04 server and am attempting to install the ubuntu-desktop gui. First, when I try to do an update: sudo aptitude update, I get an error message:
    Could not resolve ‘us.archive.ubuntu.com’. When I type this url in a browser, it resolves ok.

    When I try to sudo aptitude install ubuntu-desktop, I get the error msg: cannot find ubuntu-desktop. Any suggestions?

    Eli | Jun 26, 2008 | Reply

  55. @Eli - The problem could be several things. One possibility is that the ubuntu repository was simply not responsive when you made the request for files. If this is the case it should work eventually. Another possibility is that you don’t have your sources.list file set up correctly. Open /etc/apt/sources.list and make sure that the ubuntu repositories (Main and Universe) are present and uncommented. Do a Google search to learn more about Ubuntu repositories and the sources.list file. I hope this helps.

    Sam | Jun 26, 2008 | Reply

  56. Your instructions were exactly what I needed to get in the “front door” and start learning the system. It’s amazing how many faqs, forums, people and pages — many of which seemed very promising at first — I had to sift through before finding this one. Seriously - there’s a secret order of conspiring techies on the web, and while they pretend to offer simple “getting started” advice to potential new users, they’re actual ulterior motive is to obfuscate the solution while frustrating, antagonizing and discouraging “outsiders”. Fortuntately that’s only a joke, but unfortunately it is also the truth. Thanks for not being one of them.
    Eric

    Eric | Jun 26, 2008 | Reply

Post a Comment rss

Not sure if your comment is appropriate? View our comment policy here.

© Copyright Zaphu 2007. All rights reserved. -- Valid XHTML

Sitemap XML Sitemap XHTML