Over a million developers have joined DZone.

Deploying Drupal to heroku

DZone's Guide to

Deploying Drupal to heroku

· Java Zone ·
Free Resource

Delivering modern software? Atomist automates your software delivery experience.

Although not advised, it's actually possible to get Drupal up and running on Heroku.

First download Drupal, this is easy with drush

drush dl drupal

and install the Heroku Toolbelt. Then cd into the Drupal directory, make it a git repo and push to heroku

git init
git add .
git commit -m "initial commit"
heroku create
git push heroku master

The heroku open command will open your app in the browser, you should see the drupal installer, but we don't need this, we need to manually add settings.php and commit it to git.

heroku addons:add heroku-postgresql
heroku config

This will give you the database details you need to add to settings.php. We also need to remove (or edit) the gitignore file to let us commit settings.php.

rm .gitignore
cd sites/default
cp default.settings.php settings.php

Edit settings.php to add the database details, then commit and push to Heroku.

git add -u
git add *
git commit -m "adding settings.php and removing gitignore"
git push heroku master

Running heroku open will open your app with an error page. Add /install.php to the end of the URL and run through the Drupal installer. On the third step you will see a warning about "Unicode library". This is because the default Heroku PHP buildpack doesn't have mbstring, however you can roll your own buildpack or use a third-party one to add mbstring. For now, just click "proceed with the installation". After completing the installer you will get logged into your site and can start using Drupal.

Due to Heroku's ephemeral filesystem all files Drupal creates will not be stored if the dyno is stopped or restarted. Also some pages such as "/admin/reports/status" and "/admin/config" cause timeout errors. This issues could be resolved by creating a custom buildpack and copying all Drupal generated files to Amazon S3. Although, there are better solutions for Drupal hosting, so maybe not worth the effort.

Have fun!

Start automating your delivery right there on your own laptop, today! Get the open source Atomist Software Delivery Machine.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}