Handling Drupal

Assuming you will be creating drupal development sites, there are a few steps I recommend taking to make the process easier. First, install drush:

$ sudo apt-get install drush

Second, download the most recent drupal version into your projects directory:

$ cd ~/projects && drush dl drupal

Third, create a drupal version directory and add symlinks to your drupal download:

$ mkdir -p ~/projects/drupal7 && cd ~/projects/drupal7
$ for i in $(ls -A ../drupal-7.28 | grep -v -E [A-Z]); do ln -s "../drupal-7.28/$i" "$i"; done

The last command above, links to all the necessary files and directories to run drupal, but excludes the documentation files.

Why use symlinks

Since you may be running numerous local development environments, you can more easily keep all of your drupal instances up to date if you're using symlinks to a main repository store. By updating one directory, you can ensure that all of your drupal instances have up to date core.

Creating your drupal environment

Everything about this should be standard drupal configuration, except for symlinking. Continuing from our test development environment above, let's build a drupal environment. The hard way!

Create our core files

  • First get into the correct directory
    $ cd ~/projects/test
  • Next build our symlinks
    $ ln -s ../drupal7/* ./ && ln -s ../drupal7/.htaccess ./.htaccess
  • Now we create a 'real' sites directory
    $ mv sites notsites && mkdir sites && cp -r notsites/* sites && rm -f notsites

Create our database

As the user you created earlier, we're going to create a database for our drupal installation.

$ mysql -u USERNAME -p
mysql> create database test_drup;
mysql> exit;

Remove index.html

Since we created an index.html file in our testing environment, we now need to remove that file for drupal to load index.php.

$ rm ~/projects/test/index.html

Load the site

At this point you should be able to load your site at http://test.local and fill in the necessary information needed by the drupal installer.

The easy way

Assuming you've followed this setup exactly as described, you can use this script to create a drupal environment in the future. Just make the script executable 'chmod u+x make-drupal-dev-env.sh' and run the script with:

$ ./make-drupal-dev-env.sh

You will be prompted for the site name. You will want to enter the name without any dot extension. So something like 'mysite' will create 'mysite.local' for
you with drupal ready to be configured.