Setting up an Ubuntu PHP development environment

Post to Twitter

Today I’ll show you how to setup a PHP development environment on Ubuntu 10.10 that uses MySQL, phpMyAdmin and Apache2.


Note: I’m using VMWare Workstation to run a new/clean instance of Ubuntu 10.10 Desktop.

The first thing you need to do to follow along is to complete the steps in my previous article titled: Manually installing LAMP (Apache 2, MySQL, PHP 5) and phpMyAdmin on Ubuntu 10.10

Once you have that step completed you will be ready to finish setting up the rest of the development environment.

First you need to modify the Apache httpd.conf file to point to our home folder to setup an area where you can work on a PHP project.

$ sudo pico /etc/apache2/httpd.conf

I’m going to use port 8080 and a folder in my home directory called php-project. You can of course call this anything you want. Add the following code to the end of the file (which if your on a clean Ubuntu 10.10 system it will be blank):

NameVirtualHost 127.0.0.1:8080
Listen 127.0.0.1:8080

<VirtualHost 127.0.0.1:8080>
  DocumentRoot "/home/chadlung/php-project"
  DirectoryIndex index.php
  <Directory "/home/chadlung/php-project">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

Note: If it isn’t obvious you will need to replace my name with whatever structure you home folder looks like, it obviously won’t be this: /home/chadlung/php-project

Save the file. Create the php-project folder if you haven’t already and then reload Apache.

$ mkdir /home/chadlung/php-project
$ sudo /etc/init.d/apache2 restart

Add a new file called index.php to the /home/chadlung/php-project folder with the following content:

<?php
phpinfo();
?>

Save that file and load this address in your browser: http://127.0.0.1:8080

You should now be setup to do PHP development on Ubuntu. If you want source control using Git you can install it easily with this command:

$ sudo apt-get install git-core

You can of course seek out the various GUIs for Git as well.

Post to Twitter

This entry was posted in Open Source, PHP, Ubuntu. Bookmark the permalink.

One Response to Setting up an Ubuntu PHP development environment

  1. Geoff says:

    I’m not sure this is the “Ubuntu way” for managing sites on Apache…

    You should have a folder called /etc/apache2/sites-available/ within which you can define each site you wish to run. They then symlinked into sites-enabled using “a2ensite”

    Good writeup here: http://articles.slicehost.com/2008/4/28/ubuntu-hardy-apache-config-layout