Installing Mediawiki on a Raspberry PI3

We’ve all been there, and by all I mean ‘Technicians’, and ‘there’ I mean at job sites. And you have no idea what the password is, and your people in the office ‘may have’ the password to something you need that was written down some time ago.

Fortunately I have a effective solution that could be of some major use to you.

Well, it is 2x things. A small SBC (single board computer) called a Raspberry Pi 3 and a piece of software called ‘MediaWiki’. This is the same programme that runs ‘Wikipedia’. The site that allows anyone to edit, add, modify, correct info on the world’s largest encyclopedia site.


And with it running on a small SBC, you can leave it inside a network cabinet, as long as it is attached to some power and you should be fine.

For this project you will need the following:
  1. A Raspberry Pi 3 with a power supply and a 16 gigabyte SD-CARD with Noobs already configured on it. (See here on how it is done.) You might be able to get away with a 8gb card but I will recommend 16gb as a minimum.
  2. An internet connection.
  3. A monitor that you can be able to plug the PI3 into temporarily (at least until remote access is enabled.
  4. If you are running Windows on your pc that you will be using to remotely connect to the PI3 you will need 2 utilities. Putty and PSCP. Both are available @
  5. Knowledge of how to follow tutorials.


This tutorial will assume that you already have a pre-configured SDcard with the latest Raspbian version on it. So just just get it connected to the network via a RJ45 cable and power it on @ first.


If remote access via SSH is not enabled, you can do so via the terminal command ‘sudo raspi-config’, Selecting  ‘Interfacing Options’, selecting ‘SSH’ and selecting option to enable it.

This will also be a good time to get the IP address of the PI3 (this can be done using a network scanner looking for the network name of the PI3 <default is ‘raspberrypi’>, looking for it in your DHCP configuration on your server or router, or just by the terminal command ifconfig

Mine is currently showing that it is

Connecting to the Pi3 via SSH via Windows (PUTTY)

If you are using Windows (Linux command will follow) , this is done through Putty. Once you have downloaded and installed putty, you will need to open it up

Putty screenshot

In the field underneath ‘Host Name (or IP address) you put in your raspberry pi’s ip address, and then click connect. If may ask  you to confirm any security keys or encryption keys. Please click on yes until you see another window with it asking for a username. The default username is ‘pi’. You will need to type it in and press enter. It now should be asking for a password (if you logged in with the username as ‘pi’ the default password is raspberry).


If you are running Linux (any distribution as it doesn’t matter) you can open up a terminal and run the following command:


If you are using a different username for the pi please substitute it. Then put in the ip address of you PI3, then press enter.

If you get this after running the command, type in ‘yes’, press enter then put in the password and press enter again.

Now we can start getting the software downloaded.

Lets first download Mediawiki. The version we are going to be installing is 1.30 as this is the latest version.

Type in the following commands in order:

cd Downloads

(if the Downloads folder doesn’t exist first go ‘mkdir Downloads)

tar -xvzf mediawiki-1.30.0.tar.gz
sudo mkdir /var/lib/mediawiki
sudo mv mediawiki-*/* /var/lib/mediawiki
cd /var/www/html
sudo ln -s /var/lib/mediawiki mediawiki

Now to do the installation and updating of the software on your PI3

sudo apt-get update
sudo apt-get upgrade

Once done, run the following command the base packages required for Mediawiki.

sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring

If the packages have already been installed, the command will skip those and install the others.


During the installation of MySQL server, you will be prompted to enter a password for the MySQL root account. If for some reason no prompt is given, please run the command below.

 mysqladmin -u root password "enter the new password here"

Remember not to use same password for system root and MYSQL root.

We’re going to create a database for our MediaWiki installation to use which will be named ‘wiki’. You can use any other name you wish.

MySQL comes with a shell that can be used for configuration. We can use the the MySQL shell to create a database:

$ sudo mysql -u root -p
Enter password:
mysql> CREATE DATABASE wiki;
mysql> USE wiki;

The ‘USE temps’ command tells the shell to use that database in future operations in this shell session. MySQL supports users accounts, so we need to create a database user and give it access to the database:

mysql> CREATE USER 'wiki'@'localhost' IDENTIFIED BY 'password';
mysql> GRANT ALL PRIVILEGES ON wiki.* TO 'wiki'@'localhost'; 
mysql> quit

This creates a user called wiki , and assigns it a pass word ‘password’. This user is allowed to connect to the database from ‘localhost’.

Initially, the new user has no privileges, so it must be granted some access rights using the ‘GRANT’ command. I have used ‘ALL’ in this example, but in real world applications it would be better to grant users more limited rights. A complete list of privilege options is available at


Now you should be able on the pc you are connecting to the pi from configure Mediawiki at last! Open a new browser tab or window and browse to the following:


If you are getting a page that says ‘LocalSettings.php not found’ then click on the ‘setup the wiki first’. If you do not get that page, then you skipped a step somewhere and would need to start over.

The next few screens you will need to go over everything carefully. You can leave all of the settings as their defaults. But when you get to the database connection settings, use the same settings as in the creation of the MYSQL database which was done in the MYSQL shell moments earlier.

ON the page where it asks for a name for the wiki, you can name the wiki whatever you want it to be. For testing purposes I will call it temporary wiki. It will also ask for a username and password (last time it is asking for username’s and passwords I promise). You can even put in the email address so that it can send out emails for security purposes (and how to do that will be in a follow-up tutorial).

When you are on the last screen, click on ‘Continue’ and then leave it until another page loads asking to download the file named ‘LocalSettings.php’ save this file somewhere you can access it.

You will now need to get this file onto your PI3.

If you are running Windows:

Browse to where you saved the file ‘pscp.exe’ (Downloaded in Step 1) . In the white open space HOLD your left shift button, and RIGHT CLICK at the same time. An option to ‘open the command prompt window here’ will open. Then if you downloaded the ‘LocalSettings.php’ file to the same place then you can run the following command but if not you will need to either copy the file to where pscp.exe is or modify the command appropriately.

pscp LocalSettings.php pi@(IPADDRESS_OF_PI):/home/pi/Downloads

In a Linux terminal, browse to where you saved the ‘LocalSettings.php’ file and run the following command.

scp LocalSettings.php pi@(PI_IP_ADDRESS):/home/pi/Downloads

Once the file is there you can move it from the place we copied it to the correct place. This is done via the remote terminal with the command:

 sudo mv ~/Downloads/LocalSettings.php /var/lib/mediawiki/

Now you can go back to the same address on the same pc that we started the Mediawiki configuration (http://ip_address_of_pi3/mediawiki) and you will see the first page.

To change anything, this will be done in that ‘LocalSettings.php’ file that we moved to the Pi. I will be adding some tutorials regarding this wiki (including daily backup of the database, etc) which will come.


In the meantime please comment if I had missed anything or need some clarification I will get back to it when I can.