Speed Up Your Drupal Development Using Installations and Distributions

Do you find yourself repeating the same steps whenever you start a new Drupal project? Do you always download and enable the same modules, and make the same configuration changes every time? As we start doing more and more Drupal projects at Nomensa, I noticed that we were doing exactly this, so I started to look into ways to streamline our initial project setup process. My solution was to create my own custom installation profile that provides me with a template to start each project, and this article outlines the steps I took to create it. The code outlined in this article has been committed into GitHub at https://github.com/opdavies/linuxjournal_demo, and it's available for you to download and re-use as needed.

What Are Installation Profiles?

Installation profiles are a combination of modules and themes and predefined configuration. A great example of an installation profile that I use regularly is called Commerce Kickstart (http://drupal.org/project/commerce_kickstart). It provides a version of Drupal 7 along with the Drupal Commerce suite of modules that have been preconfigured to have the correct content types, rules, views and so on. Once an installation profile has been uploaded onto drupal.org as a project, it gets bundled with Drupal core, is available as a packaged download, and is known as a distribution. See http://drupal.org/project/distributions for a list of existing distributions.

Figure 1. The Commerce Kickstart Project Page

How to Install an Existing Installation Profile

There are two different ways to download an existing Drupal installation profile. The first (and easiest) method is to download it as a distribution from drupal.org. To do this, go to the project page for the installation profile (for example, http://drupal.org/project/commerce_kickstart), scroll to the bottom of the page, and download a release in the same way that you would download a module or theme. The resulting file will be named something like commerce_kickstart-7.x-1.10-core.tar.gz, and this file will contain both Drupal core and the Commerce Kickstart installation profile. The other option is to download a fresh copy of Drupal core, and then download the installation profile seperately, either using a drush command like drush dl commerce_kickstart, or clone it directly from its Git repository, and then place it within the Drupal's profiles directory.

Now, when you go to install Drupal, there is an additional option to use the Commerce Kickstart installation profile. Select the appropriate profile, click the Save and continue button, and continue through the installation process as normal.

Figure 2. The Installation Screen with Commerce Kickstart

How to Start Creating Your Own Installation Profile

Outside your Drupal directory, create a new directory to hold the files for your installation profile. Mine is called linuxjournal_profile, although the name of the profile is going to be simply linuxjournal. I've appended _profile to the end of the directory name. Later, there will be several different directories with similar names, so this helps provide some clarity. Be sure to give some thought to the name beforehand and ensure that it doesn't conflict with any potential modules or themes.

The first file I need to create is the linuxjournal.info file that, identical to .info files for modules and themes, defines the name and description of the profile, as well as which version of Drupal core that it is compatible with. I'm also going to make it dependent on the core dblog and block modules so that these are enabled automatically when the profile is installed:


name = Linux Journal
description = A demonstration installation profile for my LJ article.
core = 7.x
dependencies[] = dblog
dependencies[] = block

The only other mandatory file needed for this profile to be visible to Drupal is the .profile file—in this case, linuxjournal.profile. Within this file, I can put any custom PHP functions or implementations of Drupal hooks that will take effect during the installation process. For now, I'm just going to add an opening PHP tag and leave the rest of the file blank. To confirm that everything works okay so far, I can download a fresh copy of Drupal core, copy linuxjournal_profile into the profiles directory, rename it to linuxjournal so that it is the same as the name of the profile, and load that site in a Web browser.

Figure 3. The Install Screen with the Linux Journal Installation Profile

So far, so good. On the installation page, as well as seeing the default Standard and Minimal profiles, I also can see my Linux Journal profile. I can select this and continue with the installation process as normal to confirm that it's working, although because I've not entered anything into linuxjournal.profile yet, nothing special is going to happen.

Adding a .install File

Identical to writing a module, I can create a .install file that contains functions to run when the profile is installed, updated or uninstalled. I'm going to utilize the hook_install() function from the minimal installation profile as part of my profile instead of re-declaring its contents myself and duplicating code. Within my own implementation of hook_install(), I can include the .install file from the minimal profile and then run its minimal_install() function:


<?php

/**
 * @file
 * Install, update and uninstall functions
 * for the Linux Journal installation profile.
 */

/**
 * Implements hook_install().
 *
 * Run the hook_install() function from the minimal
 * profile as part of this profile.
 */
function linuxjournal_install() {
  // Utilize the hook_install() implementation from 
  // the minimal profile.
  include_once DRUPAL_ROOT . '/profiles/minimal/minimal.install';
  minimal_install();
}

Adding Modules

I'm now going to create another file called linuxjournal.make. This file contains a listing of all the projects (modules and themes) and libraries that are used within the profile. My company specializes in building accessible Web sites, and I use a number of contributed modules on every site to help me do this. There are also some essential contributed modules, such as Administration Menu (http://drupal.org/project/admin_menu) and Pathauto (http://drupal.org/project/pathauto), as well as some custom modules and features that I use on every site. All of these will be listed within the linuxjournal.make file.

______________________

Oliver Davies is an Application Developer at Nomensa, specializing in Drupal and PHP development. Outside work, Oliver is a keen contributor to the Drupal community—attending local user groups and maintaining several of his own contributed modules.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

info

Anonymous's picture

Thanks for this article. It's just what I was searching for. I am always interested in this subject. Will bookmark it.
indiaseowordpressdesigns

thanks for the information,

dherach's picture

thanks for the information, this article really helped me in performing their duties. this my blog resep ayam

Reply to comment | Linux Journal

cell port thailand's picture

cellport clinic bangkok

Feel free to visit my weblog ... cell port thailand

Reply to comment | Linux Journal

d&#039;leedon's picture

Potong Pasir MRT at the doorstep, residents can easily access almost to any destination
through.d'leedon

thanks for the information,

dherach's picture

thanks for the information, this article really helped me in performing their duties. this my blog resep ayam

The difference between install profiles and distros

marcvangend's picture

Thanks for the article. A quick note about the title: I think you meant to say "Installation Profiles" instead of "Installations".

Your article is mainly about creating installation profiles and not so much about distributions. That's okay, because installation profiles are great and they can indeed speed up your development process.

IMHO it's too easy to say that "distributions are install profiles on drupal.org" and be done with it. The big difference is that if you use a distribution, you're no longer the maintainer of that code. That has some advantages like the availability of support and updates. The disadvantage is, that if you want to change the way a distribution works, you cannot simply go in and change the code. If you did that, it would get much harder to get support and install updates. In my experience, a distribution can dramatically speed up your development process if it is exactly (or very close to) what you need. If you are planning to make a lot of changes, building on a distribution may even slow down your development process. This is especially true for distributions with lots of features and styling, such as Open Atrium.

Features / Exportables

btopro's picture

Nice article, Features, Profiler and Profiler Builder modules would all help in making a more complete export and install package (and faster) :)

White Paper
Linux Management with Red Hat Satellite: Measuring Business Impact and ROI

Linux has become a key foundation for supporting today's rapidly growing IT environments. Linux is being used to deploy business applications and databases, trading on its reputation as a low-cost operating environment. For many IT organizations, Linux is a mainstay for deploying Web servers and has evolved from handling basic file, print, and utility workloads to running mission-critical applications and databases, physically, virtually, and in the cloud. As Linux grows in importance in terms of value to the business, managing Linux environments to high standards of service quality — availability, security, and performance — becomes an essential requirement for business success.

Learn More

Sponsored by Red Hat

White Paper
Private PaaS for the Agile Enterprise

If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.

Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.

Learn More

Sponsored by ActiveState