Short url: caseywatts.com/mediawikionheroku
Unrelated update: my book is out! Debugging Your Brain is an applied psychology / self-help book
How to get set up with Mediawiki running on Heroku.
Fork https://github.com/mediawiki/mediawiki (from the web interface)
(master
worked fine for me, but you might want the last stable tag?)
git clone https://github.com/YOURUSERNAME/mediawiki
heroku apps:create YOURAPPNAME
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
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
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' );
Related: https://www.mediawiki.org/wiki/Download_from_Git#Using_Git_to_download_MediaWiki_skins
https://github.com/caseywatts/yalewiki
Compare it to mediawiki's repo to see the differences: https://github.com/wikimedia/mediawiki/compare/master...caseywatts:master
Inspiration taken from:
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