Automating Drupal 7 Installations

Installing Drupal from source is not hard. As developers there are a few ways to install Drupal in a more automated, repeatable procedure. For easier Drupal installation you can use: Drush, Drush Make and Drupal Installation Profiles.

Drush

If Drush is installed on your server you may download Drupal (core). Making a full installation of Drupal on your system as simple as:

$ drush dl drupal --select # download Drupal selecting what version 6,7,8 you want.
$ cd YOUR_DRUPAL_VERSION
$ drush site-install default --db-url=mysql://USER:PASS@locahost/DBNAME

Drush Make

Drush Make has been bundled with Drush 5.x. Drush make allows you to create an installation configuration using a file formatted a lot like an INI-file. You simply describe what modules you want installed to your Drupal website and Drush Make will download all the dependencies of your website and you can use Drush to activate them all. Given this Make file:

core = 7.x
api = 2

projects[]= drupal

; Be able to place menu blocks and navigational flows around the site.
projects[menu_block] = 2.3

; Documents should be able to be upload to site centrally. Images should be
; able to be resized in WYSIWYG editor. We should allow folders/tagging of
; images.

; centralized media vault like support
projects[file_entity] = 2.0-unstable7
projects[media] = 2.0-unstable7

; folders/tagging support
projects[media_browser_plus] = 2.x-dev
projects[wysiwyg] = 2.2
projects[image_resize_filter] = 1.13
projects[views] = 3.5
projects[multiform] = 1.0
projects[colorbox] = 2.2

; caption support
projects[jcaption] = 1.3

; We eventually will use this for Active Directory LDAP integration support.
projects[ldap] = 1.x
projects[apc] = 1.0-beta4
projects[module_filter] = 1.7

; dependencies of wysiwyg module.
projects[libraries]=  2.0

; 3rd party libraries.
libraries[ckeditor][type] = "libraries"
libraries[ckeditor][download][type] = 'file'
libraries[ckeditor][download][url] = 'http://download.cksource.com/CKEditor/CKEditor/CKEditor%203.6.3/ckeditor_3.6.3.zip'

You would install it as:

$ drush make example-site.make my_docroot_dir

Drush Make in my opinion feels slightly limiting in that it just downloads things and puts them in the default directories. It supports 3rd party libraries a little — but configuring complicated values with slight modifications per site (in the database) seem difficult. Placing files outside of typical Drupal directory configurations feels difficult…is there a workaround? Yes!

Drupal Installation Profiles

Drupal ships with, and every single site administrator uses, Installation Profiles. They are the web interface you use to install Drupal: configure the storage mechanism (Database), Language Localization and Administrator user. Drush’s site-install core function also loads and executes a given Installation Profile.

An Install Profile is very similar to Drupal module. In fact in a Drupal 7 installation the default Profiles can be found in the /profiles/ directory. They are simply PHP files. They do things such as: define default content types and their fields, setup Permissions, Input Formats and create and enable default blocks and Themes. An Install Profile is way to write PHP to completely 100% control how Drupal is installed on a system. Modules for an Installation Profile live in the /profiles/PROFILE_NAME/modules/ directory.

A profile directory contains the profile itself, and typically acts like a small drupal /sites/ directory, it can have its own set of Core or Contrib module directories, libraries directory and themes directory.

Modules, Libraries and Themes found within a Profile directory are visible and used by Drupal sites installed with that Profile. Drupal scans various locations for modules and themes when resolving the dependencies for a given Drupal site. Drupal scans like the: Profile directory, sites/SOMESITE/, sites/all and then the default site directory for site files. This is similar to how Applications and Fonts may live in different locations on a system for any given user of system in OSX. I gave a full explanation of this scan-for-site-modules Drupalism in this Stackexchange thread.

Here is a link to a small custom module I wrote for Drupal 7 which slims down 1 of the default profiles by making a default selection and removing that screen from the web UI of the Drupal installation. Install Profiles are very powerful — and slightly cumbersome to make.

A possibly awesome best-of-all-worlds solution…

Drush Make + Profiler Module

The Profiler module is a Contributed module for Drupal 7. It allows you to create a Drupal Install Profile using essentially a super-set of options seen in Drush Make. Let that sink in … you can make a recipe for your site dependencies using Drush make, with hooks and even drupal.info file like markup for enabling modules and simple content creation:

dependencies[]= ctools
nodes[1][title]= sample node
nodes[1][body]= <p>this is a node body ...</p>

This allows you to create a complete reproducible recipe for a Drupal website in a simple recipe like file format you can version in Git and update as needed. I don’t see this approach used much by the Drupal community — but it has its merits. For further details on how to use the Profiler module be sure to read the Profiler README file as it has complete and the Example Profiler module.

Looking for quality Drupal Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , | Posted under Drupal | RSS 2.0

Author Spotlight

David Gurba

David Gurba

I am a web programmer currently employed at UCSB. I have been developing web applications professionally for 8+ years now. For the last 5 years I’ve been actively developing websites primarily in PHP using Drupal. I have experience using LAMP and developing data driven websites for clients in aviation, higher education and e-commerce. If you’d like to contact me I can be reached at david.gurba@arvixe.com

Leave a Reply

Your email address will not be published. Required fields are marked *


3 × = 6

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>