Published: Sat 28 Jun 2014

How to create a Drupal Installation Profile the easy way

It's not rocket science, this building installation profiles/distributions with Drupal!

Creating your own Drupal installation profile is a great way to save time when building a new website if you have many features that you use again and again on projects, such as news content type, image galleries, rotating slider. It's a great way to store your configuration in code and build and rebuild your site while in development. It's also best practice if you want to share code and rebuilds between developers working on large projects.

So, how do ywou make an installation profile, the easy way? The easiest way to create an installation profile is to just copy one that comes with Drupal core and modify it. To do this;

  • Open up your profiles folder, find the folder called "standard" and copy it, then rename it to whatever you want. I call mine "adfl" as I do work as a freelancer under the name "A Design for Life".
  • Next, rename each file in your new folder from standard.profile to adfl.profile, standard.install to adfl.install, standard.info to adfl.info.
  • In the .info file, edit the description to something more meaningful for your installation profile.
  • Finally, open each file and replace the word "standard" in the code with the word "adfl".

You now have a working installation profile called adfl, but it does the exact same as the standard installation profile. Let's customise it.

In the .info file, you'll see a number of modules already installed, like so:

dependencies[] = block
dependencies[] = color
dependencies[] = comment
dependencies[] = contextual
dependencies[] = dashboard
dependencies[] = help
dependencies[] = image
dependencies[] = list
dependencies[] = menu
dependencies[] = number
dependencies[] = options
dependencies[] = path
dependencies[] = taxonomy
dependencies[] = dblog
dependencies[] = search
dependencies[] = shortcut
dependencies[] = toolbar
dependencies[] = overlay
dependencies[] = field_ui
dependencies[] = file
dependencies[] = rdf

We can turn these off by deleting some, like so (or simply placing a semi-colon before them to comment them out):

dependencies[] = block
dependencies[] = comment
dependencies[] = contextual
dependencies[] = image
dependencies[] = list
dependencies[] = menu
dependencies[] = number
dependencies[] = options
dependencies[] = path
dependencies[] = taxonomy
dependencies[] = dblog
dependencies[] = search
dependencies[] = field_ui
dependencies[] = file
; this is commented out dependencies[] = overlay
dependencies[] = rdf

Now, if you reinstall your website, you'll see that we only have the above modules installed. We can now add in some modules that we use on every website. Place these modules in profiles/adfl/modules/contrib. We add them like so:

dependencies[] = admin_menu dependencies[] = ctools dependencies[] = features dependencies[] = views

Keep adding whatever modules you need. Now, when you resinstall your site drush si adfl, you'll see these modules also installed. To add custom functionality, you create features, and then add those features to your install profile, like so:

dependencies[] = adfl_blog dependencies[] = adfl_views_blog dependencies[] = adfl_gallery dependencies[] = adfl_views_gallery

A new site install will have these features enabled as well. A site install gives some simple errors at the moment: since I don't have dashboard enabled, the blocks placed in the dashboard can't be placed. Opening the .install file, we can find where this is and delete it:

array( 'module' => 'search', 'delta' => 'form', 'theme' => $default_theme, 'status' => 1, 'weight' => -1, 'region' => 'sidebar_first', 'pages' => '', 'cache' => -1, ), array( 'module' => 'node', 'delta' => 'recent', 'theme' => $admin_theme, 'status' => 1, 'weight' => 10, 'region' => 'dashboard_main', 'pages' => '', 'cache' => -1, ), array( 'module' => 'user', 'delta' => 'login', 'theme' => $default_theme, 'status' => 1, 'weight' => 0, 'region' => 'sidebar_first', 'pages' => '', 'cache' => -1, ),

In the above case, we need to delete the array

array( 'module' => 'node', 'delta' => 'recent', 'theme' => $admin_theme, 'status' => 1, 'weight' => 10, 'region' => 'dashboard_main', 'pages' => '', 'cache' => -1, ),

Then, just keep building up your profile with features, theme, variable settings, etc. There you go, a custom installation profile, the easy way. (Might be better to start with minimal as your base, I'm only using standard for illustration.)

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.