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 comment has been minimized.

AlessandroChecco commented Apr 23, 2017

This line should be removed now

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


This comment has been minimized.


caseywatts commented May 29, 2017

ooh thanks @AlessandroChecco !


This comment has been minimized.


caseywatts commented May 30, 2017

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


This comment has been minimized.

curtiscook commented Jun 7, 2017

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


This comment has been minimized.


caseywatts commented Jun 15, 2017

Thanks @curtiscook! added that in, too :)


This comment has been minimized.

lazaropj commented Jul 3, 2017

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


This comment has been minimized.


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


This comment has been minimized.

francisli commented Mar 24, 2018

Thanks for providing this great resource! I also configured SMTP mail support with the MailGun add-on by adding the following to LocalSettings.php:

$wgSMTP = array(
 'host'     => getenv("MAILGUN_SMTP_SERVER"), // could also be an IP address. Where the SMTP server is located
 'IDHost'   => getenv("MAILGUN_DOMAIN"),      // Generally this will be the domain name of your website (aka
 'port'     => getenv("MAILGUN_SMTP_PORT"),                 // Port to use when connecting to the SMTP server
 'auth'     => true,               // Should we use SMTP authentication (true or false)
 'username' => getenv("MAILGUN_SMTP_LOGIN"),     // Username to use for SMTP authentication (if being used)
 'password' => getenv("MAILGUN_SMTP_PASSWORD")       // Password to use for SMTP authentication (if being used)

As well as adding the necessary pear packages to the compose.json and the lockfile (run on the command line):

$ compose require pear/mail pear/mail_mime pear/mail_mime-decode pear/net_smtp pear/auth_sasl

Then commit your changes and push!

Also note that I was able to get up and running with JawsDB Maria db add-on on the free tier...


This comment has been minimized.

francisli commented Mar 24, 2018

I'd recommend for Heroku deployments to set the cache directory:

$wgCacheDirectory = "/tmp";

Otherwise, it will default to storing/fetching localization cache data in the DB, which will run up your query and data count against limits (certainly, against the free tier of dbs).

I'll also be looking into submitting a patch back to MediaWiki for supporting SASL auth on memcached, which will allow using any of the memcache add-ons for object caching, which should also reduce load on the db...

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