Skip to main content
info@drupalodyssey.com
Thursday, February 12, 2026
Contact

Main navigation

  • Home
  • Services
  • Case Studies
  • Blog
  • Resources
  • About
Search
Development

Learn How To Script Drupal Installations Using Drush

December 08, 2014
This article is depreciated as of Drupal 8 in favor of a Composer workflow.

I've been using Drupal for several years now and love the content management system. It seems that every day I find something else about Drupal or a specific custom module or add-on that makes it better and better. Recently, I discovered the power of using a shell script along with the Drush command line utility to install and set up an entirely new site in a matter of minutes.

I've known about Drush, the command-line utility for Drupal, for awhile now but only recently starting using it and digging through the docs to see what it's actually capable of. Today was the day I unlocked the golden door to consistent and simplified installations — the site-install or si command with shell scripts.

The reason I started looking into this is that at my job, we use Puppet to control our system builds so they are predictable. Our Drupal skeleton worked, but someone still had to open the new site in a browser and run the Drupal installation manually. Ugh! There had to be a better way! That's when I started researching Drush installations.

I'm not a shell script guru by any means, but with what I do know and some help from the Drush documentation, I was able to throw together a working script that simulates closely what our Puppet manifest does when creating a new Drupal site in less than an hour.

Feel free to use and extend the following shell script (written for OS X Yosemite‎). Just substitute the variable values with values for your system.

#!/bin/sh # 
# This is a basic shell script to install a previously downloaded tarball 
# of Drupal core to create an entirely new site. The settings variable is set 
# because I have a pre-configured "default.settings.php" file with 
# configuration variables pre-set with values that I use most often for new 
# Drupal sites which is stored in a known location on my file system. The 
# default.settings.php file is removed from the extracted Drupal core archive 
# and replaced with my customized file BEFORE the Drush installation runs. 
# 
# Drupal core source file. 
source=/Users/ronald/Downloads/drupal-7.34.tar.gz 
# Target directory for the installation
target=/Users/ronald/sites/dev/drupaltest.com/htdocs 
# Pre-edited 'default.settings.php' file location 
settings=/Users/ronald/drupal/config/default.settings.php 
# Database configuration string. 
db_settings=mysql://dbuser:dbpass@dbhost:3306/dbname 
# Drupal super user to create (UID 1) 
user=admin 
# Drupal super user password 
pass=xxxxxx 
# The site name sitename="Drush Install Test" 
# The site email address 
sitemail=support@somedomain.com 
# First - untar the archive file into the target directory. 
/usr/bin/tar -xf $source -C $target --strip-components=1 
# Second - Remove the file sites/default/default.settings.php from the 
# the extracted files. 
rm "$target/sites/default/default.settings.php" 
# Third - Copy the edited version of 'default.settings.php' into the 
# sites/default folder so Drush will have that file available 
# to copy to settings.php when the installation runs. 
# 
cp $settings "$target/sites/default/default.settings.php" 
# Fourth - Change to the $target directory and use Drush to install the 
# Drupal site in that directory. 
# 
cd $target; drush si standard --db-url=$db_settings --account-name=$user --account-pass=$pass --clean-url=1 --site-name=$sitename --site-mail=$sitemail --locale=en -y
NOTICE: The above script is provided as-is with no warranty. I am not responsible for system damage or data loss. Use the above script at your own risk.
Author

Ron Ferguson

 

Next Blog

0 Comments

Login or Register to post comments.

Ad - Header (728*90 AD)

Ad - Sidebar (300 x 600 AD)

Ad - Sidebar (300 x 250 AD)

Newsletter

Subscribe my Newsletter for new blog and tips.

Menu

  • Home
  • Services
  • Case Studies
  • Blog
  • Resources
  • About

Legal

  • Privacy Policy
  • Terms & Conditions
  • Disclaimer
  • Cookies

I specialize in custom development, performance tuning, and reliable maintenance, delivering clean code and strategic solutions that scale with your business. Ready to discuss your project?

E: info@drupalodyssey.com
Fort Worth, TX

© 2026 All Rights Reserved.

Proud supporter of active military, veterans and first responders.