Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Mediawiki on Heroku

Short url:

How to get set up with Mediawiki running on Heroku.

Create Git Repo

Fork (from the web interface)

(master worked fine for me, but you might want the last stable tag?)

git clone
heroku apps:create YOURAPPNAME

composer.lock setup

Mediawiki's repo doesn't have a composer.lock in it, and Heroku requires one. (I wish I knew more about why they didn't check that in?)

Before being able to generate a composer.lock, you may need to get php installed using brew see here (brew is for OSX). Packagist require you use a not-old version of openssl in your php, or else it won't let you download packages from it. Installing through brew gets a newer version of openssl bundled into your install of php.

Generate and add to the repo a composer.lock

brew install composer
composer update
git add -f composer.lock
git commit -m "add composer.lock"
git push heroku master

Configuring with ClearDB

Install an instance of ClearDB, either through the Heroku Dashboard or CLI. The free database isn't enough, you'll probably need the cheapest paid one ('punch', not 'ignite').

heroku addons:create cleardb:punch

Get the database information from the CLEARDB_DATABASE_URL ready to use soon mysql://USERNAME:PASSWORD@HOST/TABLENAME (and there is no table prefix)

heroku config

Now go to your deployed Heroku app, and follow the setup wizard. Put in the database information where requested.

Once you're done, you'll have to download LocalSettings.php and change some things before checking it into the repo. DO NOT check in LocalSettings.php with the passwords still in it. Instead, we'll use ENV vars.


Replace the ## Database settings sesction of LocalSettings.php with this (based on this):

## Database settings
$url = parse_url(getenv("CLEARDB_DATABASE_URL"));

$wgDBtype = "mysql";
$wgDBserver = $url["host"];
$wgDBname = substr($url["path"], 1);
$wgDBuser = $url["user"];
$wgDBpassword = $url["pass"];

Move the $wgSecretKey into an ENV var:

$wgSecretKey = getenv("SECRET_KEY");

Also move the $wgUpgradeKey into an ENV var:

$wgUpgradeKey = getenv("UPGRADE_KEY");

Now you can add, check in, push the new file "LocalSettings.php"

git add -f "LocalSettings.php"
git commit -m "add LocalSettings.php"
git push heroku master

Installing a Skin (Vector)

You can install the vector skin by adding it to the composer.json - add a line something like this (followed by composer update):

"mediawiki/vector-skin": "dev-wmf/1.30.0-wmf.2",

Then you'll have to add the skin explicitly to the bottom of LocalSettings.php like the instructions on the deployed site say to do (but what is the default skin for if it's not used??):

wfLoadSkin( 'Vector' );


An Example Setup

Compare it to mediawiki's repo to see the differences:


Inspiration taken from:

This line should be removed now

echo "web: vendor/bin/heroku-hhvm-apache2" >> Procfile


caseywatts commented May 29, 2017

ooh thanks @AlessandroChecco !


caseywatts commented May 30, 2017

I ended up being able to remove a lot just now, and also found some more gotchas 🎉

you should move the secret keys for sessions & upgrades to environment parameters as well :)


caseywatts commented Jun 15, 2017

Thanks @curtiscook! added that in, too :)

lazaropj commented Jul 3, 2017

I could not install using the free database. I think it is necessary to have the plan paid.


caseywatts commented Aug 17, 2017

ooh I had to use the paid one too actually - thanks for commenting that @lazaropj! !
Updated the instructions above to create a paid version cleardb:punch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment