Wednesday, January 23, 2019

MediaWiki Installation on Raspberry Pi

Success!

If you ask me why I would want to install MediaWiki on a Raspberry Pi I'll give you the same answer George Mallory gave when asked why he wanted to climb Mount Everest:
Because it's there.
Which is just another way of saying because I want to.

Anyway, I installed MediaWiki on a Raspberry Pi and this is how I did it.

If you don't already know a Raspberry Pi is:
The Raspberry Pi is a series of small single-board computers developed in the United Kingdom by the Raspberry Pi Foundation to promote teaching of basic computer science in schools and in developing countries...
Raspberry Pi 3 Model B was released in February 2016 with a 1.2 GHz 64-bit quad core processor, on-board WiFi, Bluetooth and USB boot capabilities.
So what is MediaWiki? I'll let them explain it for themselves:
MediaWiki is a free and open source software wiki package written in PHP, originally for use on Wikipedia. It is now also used by several other projects of the non-profit Wikimedia Foundation and by many other wikis...

First things first, the hardware. I used the following:
  • Raspberry Pi Model 3 B Ver 1.2
  • 32 GB Micro SD Card
  • Raspberry Pi Case
  • Western-Digital WD Labs PiDrive (312 GB hard drive)
  • Western-Digital WD Labs PiDrive Enclosure Kit
  • 3A Power Supply with Integrated On/Off Switch
  • Double-sided Foam Tape (for mounting)
  • A spare keyboard and HDMI monitor/cable for initial set up
I used the double-sided foam tape to mount the Raspberry Pi case on the PiDrive case. Western-Digital has discontinued WD Labs and the PiDrive. I included it for future use. It's not needed to get MediaWiki running on the Raspberry Pi.

Next, the software:
  • Raspian Stretch Light 13 Nov 2018
  • MediaWiki 1.32.0
  • apache2
  • mysql-server
  • php
  • php-mysql
  • libapache2-mod-php
  • php-xml
  • php-mbstring
  • php-apcu
  • php-intl
  • imagemagick
  • inkscape
  • php-gd
  • php-cli
  • php-curl
  • git
Sounds like a lot of software, but the MediaWiki installation instructions make it mostly easy.

Basic set up the Raspberry Pi is explained in plenty of other places. In brief:
  • Burn the Raspian Stretch Lite image to the SD card (I use Win32 Disk Imager)
  • Install the SD card in the Pi and connect it to the keyboard and monitor
  • Log in as user pi with default password raspberry
  • Run sudo raspi-config
  • Using raspi-config, change the password, hostname, set up your wifi, change localization settings to your area, and enable ssh
  • You can also set up the Pi to autologin to the user pi on boot, but it is not recommended
  • Reboot (raspi-config will prompt you to do so)
  • Login and make a note of the wifi IP address using the command ifconfig -a
  • I set up a static IP address for the Pi in my router and just let the Pi do DHCP when it boots
  • Shut down the pi with command sudo shutdown
  • Disconnect keyboard and monitor
Once the Pi  was set up I put it in its permanent location and turned it on. Installation of MediaWiki was done over ssh (I used PuTTY on a Windows 10 PC).

As I mentioned above the MediaWiki installation instructions are mostly easy and I won't reproduce every step here. I'll just make a few comments and suggestions.

The Raspian operating system in based on Debian, so the installation instructions for Debian are what I used.

It is very important to be sure the Pi installation is current before attempting to install MediaKiki (or anything else, for that matter). So don't skip the first step:
sudo apt-get update && sudo apt-get upgrade
The latest version Raspian Stretch and Stretch Lite includes PHP 7.0 so use the command to install LAMP with PHP 7.0:
sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring
Install all of the optional packages:
sudo apt-get install php-apcu php-intl imagemagick inkscape php-gd php-cli php-curl git
sudo service apache2 reload
After I completed the rest of the installation and tried to log into the new wiki I received the following error:
There seems to be a problem with your login session; this action has been canceled as a precaution against session hijacking. Go back to the previous page, reload that page and then try again.
After some Googling I found the answer. Bottom line is I had to edit /var/lib/mediawiki/LocalSettings.php:
sudo nano /var/lib/mediawiki/LocalSettings.php
And change the $wgSessionCacheType entry to:
$wgSessionCacheType = CACHE_DB;
Finally I edited some clip art to make a logo, uploaded it to the Pi and edited LocalSettings.php and I was up and running.

So, like the dog that finally caught the car he was chasing, now what do I do?

No comments: