Setting Up a Media Wiki using Laravel Forge

I was recently in a conversation about Football (a sport which I know very little about) and thought it would be useful if there was a site for people to swot up on popular conversation topics. So I decided to set up a Wiki to crowd source not only information, but also opinions and "banter" subjects.

Laravel Forge is my deployment system of choice, but all of my projects since using Forge have been Laravel projects. So, it was first time I was setting up a mediawiki and the first time I was deploying a non-Laravel project on Forge.

First of all, set up your repository. In my case I used Github. Then, add the mediawiki repo as an upstream. This will allow the codebase to be updated with ease. Checkout the latest stable branch (in my case 1.26.3). Then create a new master branch off of the tag and push to your origin. Once you have initialised your repo, you can use the following commands:

git add remote upstream
git checkout 1.26.3
git checkout -b master
git push -u origin master

Set up a new Laravel Forge site and add you repo. Laravel Forge has a default deploy script aimed at Laravel deployment, this will need to be edited in order to deploy a mediawiki site. For now, just remove the `php artisan migrate --force` line.

Now you can visit the site and start running through the setup steps. Part way through, you might come across a warning about the uploads directory. The warning will have a link on how to deal with the problem in Apache, but not Nginx (which is what Forge uses). Add the following line to the end of the server block in your Nginx configuration (found from SF).

location ^~ /images/ { }

Once the setup process has been completed, you should be offered a settings file to download. Proceed to download this and add it to the root of your codebase. This file contains all your passwords, which of course, you don't want to commit to version control. Instead of explicitly defining the confidential information, replace it with `getenv('blah')`. For example:

$wgSecretKey = getenv('wgSecretKey');

You can now add the settings file to version control without worrying about people finding out the credentials. But the private credentials need to be added to the server environment. Edit your Nginx files again and add in all the data above the line `include fastcgi_params;`. For example:

fastcgi_params wgSecretKey "secretkey";

And now the Wiki should be set up and ready to go!

Adding a new theme/skin

Choose your theme from the website. I chose "Vector". Then edit your deploy script on Forge and add the following lines to the end:

cd skins
rm -rf Vector
git clone

Setting up a rewrite rule

By default, the path is `/wiki/`, but it is possible to write a rewrite rule to change this. I chose to make mine "2". I also wanted to have the article name look like a directory instead of a query parameter. If you would like to do the same, add the following somewhere in the Nginx file server block:

location {
    rewrite ^/2([^?]*)(?:\?(.*))? /index.php5?title=$1&$2 last;