Friday, October 8, 2010

Web Developer Testing Server Setup: Ubuntu LAMP Step-by-Step

As a web developer, we need a server on our LAN to test our work before we put it online. Testing on a standalone machine is both more realistic and less intrusive than running a web server on one of our work computers. Until recently our testing server was running OpenSolaris 2009.06, but Oracle has pulled the plug on OpenSolaris. I decided to take a look at Ubuntu Linux and found setup to be straightforward. Using Ubuntu 10.04.1 Lucid Lynx, a lot of the work has been done for you, with just a couple of gotchas along the way.
You will be required to choose passwords at various points during this procedure. Since our server will live behind a firewall on our LAN and is only for testing purposes, I used the same password throughout for simplicity. This is not recommended for a server that will see live deployment.
Click on any of the images in this article to zoom in.
  1. Download the 32-bit or 64-bit disk image, depending on your hardware, and burn it to a CD. Our server is an old Dell Dimension 3000 so we're running the 32-bit release.
  2. Boot your server from the CD. Select your language, then choose the first menu option, "Install Ubuntu Server".
  3. Proceed through the installation until you reach this screen:
  4. Select "LAMP server" to install the Linux Apache/MySQL/PHP combo. I also selected "OpenSSH server" so I could administer the server from anywhere on our LAN, without having to walk up to the machine.
  5. When the installation is complete the server will reboot. Login and make a note of the IP address assigned to the machine. This is the address you'll use for transferring files using FTP, testing websites, and remote admin (if you installed OpenSSH).
  6. Execute the following command to install phpMyAdmin, for easy management of your MySQL databases:
    sudo apt-get install phpmyadmin
  7. At this screen select apache2:
  8. At this screen select "Yes":
  9. When the phpMyAdmin installation is done, complete the following four steps to stop phpMyAdmin from complaining that "The additional features for working with linked tables have been deactivated..."
  10. Execute the following command:
    sudo nano /etc/phpmyadmin/config.inc.php
  11. Scroll down until you see this:
  12. Add the following line:
    $cfg['Servers'][$i]['tracking'] = 'pma_tracking';
  13. Press Control-o to save the file, Enter to confirm the filename, then Control-x to quit the editor.
  14. Complete the following three steps to stop apache2 from complaining that it "Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName".
  15. Execute the following command:
    sudo nano /etc/apache2/conf.d/fqdn
  16. Enter the following text:
    ServerName localhost
  17. Press Control-o to save the file, Enter to confirm the filename, then Control-x to quit the editor.
  18. To install an FTP server for file transfer using DreamWeaver or similar, execute the following command:
    sudo apt-get install vsftpd
  19. Enter the following command to edit the vsftpd configuration file:
    sudo nano /etc/vsftpd.conf
  20. Scroll down until you see this:
  21. Uncomment the write_enable and local_umask lines to look like this:
  22. Press Control-o to save the file, Enter to confirm the filename, then Control-x to quit the editor.
  23. Take ownership of the web hosting directory by entering the following command (replacing <your user name> with the user name you created during the Ubuntu installation):
    sudo chown <your user name> /var/www
  24. Restart your server by entering the following command:
    sudo reboot
  25. Test your web server by entering the IP address you noted earlier into your browser. If it's working you will see a message like this:
  26. Test phpMyAdmin by appending "/phpmyadmin" to the IP address.
  27. If you're in an environment that supports Bonjour (aka Zeroconf), e.g. if you're running Mac OS, execute the following command:
    sudo apt-get install avahi-daemon
  28. Now you will be able to access your testing server by name instead of IP address. Just append ".local" to the name that you gave your server during installation ("ubuntu" by default).
If you find this guide useful I'd love to hear from you.

3 comments:

  1. Excellent guide! I've recently setup a LAMP server on Ubuntu 10.10 via VMware running on an XP host (boooo I know.) It's working wonderfully so far! Thank you!

    ReplyDelete
  2. Hi Cole, I'm glad you found it useful, thanks for letting me know.

    ReplyDelete
  3. Thanks for the this! The only things this guide needs to be the best guide ever is if you add 1) subversion, 2) multiple apache hosts and finally 3) webdav.

    Thanks for the guide!

    ReplyDelete