I upgraded my local computer to Ubuntu 12.04 today and revisited my Drupal development environment. Here is a simple and fast guide how to configure Ubuntu for development. There are a number of installation documentation pages on this topic on drupal.org, but they suggest to use the packaged Drupal installation and to run Drupal in subfolders (e.g. http://localhost/drupal6). They also do not cover some other important development tools like Phpmyadmin or php.ini settings. During development we want to edit files and we want to do that somewhere in our home directory to avoid any permission problems. There is also Drubuntu, but it is outdated and does way too much magic in my opinion. So here is a more transparent tutorial that highlights the key development configuration settings for Drupal development.


To install a web server and MySQL and PHP and all the dependencies we simply install the default Ubuntu drupal package:

sudo aptitude install drupal7

The installation will probably prompt you for a few things: Set a password for the MySQL root user. For the Postfix configuration you can select the "Local only" profile, so that no outgoing mail will be sent by PHP from your computer. For the postfix system mail name you can just leave it at your default hostname. The installation will probably prompt you to configure a default drupal database, but we will do that manually afterwards, so skip it.

We don't want to expose any of our sites to the outside world, so we limit Apache to only listen on the localhost interface. Edit /etc/apache2/ports.conf and replace "Listen 80" with "Listen".


We want Apache to run as our own user account to avoid any permission problems or conflicts when running drush or editing config files. Edit /etc/apache2/envvars and change the user to your account name. Example:

export APACHE_RUN_USER=klausi
export APACHE_RUN_GROUP=klausi

Enable the Rewrite mod and restart Apache.

sudo a2enmod rewrite
sudo service apache2 restart

Now we would like to have Phpmyadmin to easily create, inspect and manipulate MySQL databases.

sudo aptitude install phpmyadmin

The installation will probably prompt you for a few things: Confirm that you want to automatically configure a database with dbconfig-common. Select Apache as web server to configure automatically.

Now your Phpmyadmin installation should be reachable at http://localhost/phpmyadmin/ .

We will need some tools for development:

sudo aptitude install git php5-xdebug php5-curl php-apc


It is important to tune your /etc/php5/apache2/php.ini for development purposes. I changed the following entries:

memory_limit = 256M
error_reporting = E_ALL | E_STRICT
display_errors = On
display_startup_errors = On
track_errors = On
html_errors = On
session.gc_probability = 1

Folder setup

The next step is the setup of a workspace environment in my home folder where I will develop my Drupal projects. Example for my "drupal-8" development environment:

  • Drupal root: /home/klausi/workspace/drupal-8
  • Apache config: /etc/apache2/sites-available/drupal-8
  • Browser: http://drupal-8.localhost
  • Database: drupal-8

Checkout Drupal 8:

cd ~
mkdir workspace
cd workspace
git clone --recursive --branch 8.x http://git.drupal.org/project/drupal.git drupal-8

Apache config

Create an Apache configuration for your drupal-8 folder at /etc/apache2/site-available/drupal-8:

<VirtualHost *:80>
        ServerAlias drupal-8.localhost
        DocumentRoot /home/klausi/workspace/drupal-8
        <Directory "/home/klausi/workspace/drupal-8">
                Options FollowSymLinks
                AllowOverride All

Enable the configuration and restart Apache:

sudo a2ensite drupal-8
sudo service apache2 restart

You might wonder why I do not use an Apache wildcard/catchall configuration, here is the reason why: unfortunately the VirtualDocumentRoot directive requires that you modify your .htaccess in your Drupal installation (you have to enable the RewriteBase /). This is bad because then you always have local changes in that file if you are working with a Drupal core git checkout.

localhost DNS

Create the domain entry for drupal-8.localhost in /etc/hosts. Add " drupal-8.localhost". You will have to add each new project name in this file (you could also install Bind to automatically resolve this, but seems like an overkill to me).

I wrote a simple bash script that automatically creates the Apache site config and the site's hosts entry for me. Make sure to change the WORKDIR to your directory and run it like this:

sudo deploy-site.sh drupal-8


Create the database in Phpmyadmin: Go to http://localhost/phpmyadmin , then "Privileges", then "Add a new User". Fill out the user name with "drupal-8", host localhost and generate a password (copy that password to use it later during the Drupal install process). Use the "Database for user" section and select "Create database with same name and grant all privileges".

Install Drupal

Now your Drupal installation should be reachable in your browser at http://drupal-8.localhost and you can start the installation. Done!

Development tips