Setting up a nice LAMP development environment on Ubuntu

Ubuntu logoThis is more to aid my memory the next time I have to set up a LAMP development environment on a fresh install of Ubuntu (can you tell what I’ve been up to this weekend?). The nice thing about starting from a blank slate is that it gives me a chance to really think through the overall installation setup and find solutions to issues that I’m normally too busy to track down.

Note: this is intended for local development purposes only, not production servers.

  1. Set up the base LAMP system
    sudo apt-get install apache2 php5 php5-cli php5-mysql mysql-server mysql-client

    Note: for ease of development access, I prefer to leave the root MySQL password blank.

  2. Set up some optional but useful PHP modules
    sudo apt-get install php5-gd php5-curl php5-sqlite php-pear smarty
  3. Set up subversion for source code control
    sudo apt-get install subversion
  4. Set up postfix and alpine (like Pine) for sending and checking email locally
    sudo apt-get install postfix alpine
  5. Prevent Apache error “Could not determine the server’s fully qualified domain name”
    echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn
  6. Enable public_html userdirs, e.g. http://localhost/~username/
    sudo a2enmod userdir
  7. Enable url rewriting for pretty URLs
    sudo a2enmod rewrite
  8. Restart Apache
    sudo service apache2 restart

3 Comments

I removed the section on editing userdir.conf to enable full .htaccess support because that doesn’t seem to be an issue with Ubuntu anymore (as of v8.10).

Justin,

Thank you so much for this.. I found myself in a position where I had to reinstall my local development LAMP server and this page saved me SO much time!

-sako

Added a step for setting up alpine and postfix, which is useful if your web app ever sends email.

Name

Email (optional)

Blog (optional)