Some links in this post may be affiliate links. We may get paid if you buy something or take an action after clicking one of these, but without addictional costs for you compared to direct buying.

Personal Mediawiki with Raspberry PI and Docker

Raspberry PI Mediawiki featured image

What Is MediaWiki

MediaWiki is an open source collaboration and documentation platform used to share knowledge between people across Internet. It is at base of famous Wikipedia website.

Mediawiki logo

Licensed under GNU General Public License (GPL), it is extremely powerful, scalable and feature-rich. MediaWiki uses PHP for its front-end to display information to your browser and a number of databases variety (most common being MySQL).

In this article I’m going to show you how to create your personal wiki with the cheap and powerful Raspberry PI. To simplify installation and setup, I’ll use Docker and docker-compose to deploy services with a single command line and a few configuration files. Instead of MySQL, our database will be built on custom MariaDB installation (fork of MySQL), which is performing better on Raspberry PI boards.

I will use a Raspberry Pi 3 model A+, but this guide will work also with newer Raspberry PI boards. You can check hardware differences with Raspberry PI comparison between latest models.

What We need

RPI 3 model A+

As usual, I suggest adding from now to your favourite e-commerce shopping cart all needed hardware, so that at the end you will be able to evaluate overall costs and decide if continuing with the project or removing them from the shopping cart. So, hardware will be only:

Check hardware prices with following links:

Amazon raspberry pi boards box
Amazon Micro SD box
Amazon Raspberry PI Power Supply box

Step-by-Step Procedure

Environment Preparation

Start from a fresh Raspberry PI OS Lite installation. Then make sure your operating system is updated and upgraded:

sudo apt update
sudo apt upgrade

Our environment will be completed installing Docker and docker-compose (using linked procedure).

Installing Database and MediaWiki

Using docker will result in a huge simplification for installation procedure. Create a directory that will include our configuration files. Consider that by default, docker-compose will prepend to containers your directory name, even if you can easily edit it later. From terminal:

mkdir mediawiki
cd mediawiki

Following files will be created in this directory:


Docker-compose yaml file

Create a docker compose file:

nano docker-compose.yml

and add following code;

# My MediaWiki
# from
version: '3'
  image: mediawiki
  restart: unless-stopped
   - 8080:80
   - database
   - mediawiki-www:/var/www/html
 #After initial setup, download LocalSettings.php to the same directory as
 #this yaml and uncomment the following line and use compose to restart
 #the mediawiki service
 # - ./LocalSettings.php:/var/www/html/LocalSettings.php
  build: .
  restart: unless-stopped
   - mediawiki-db:/var/lib/mysql

As you can see, our database will be built on custom installation (please refer to create custom MariaDB container on Raspberry PI for more info).


Create a Dockerfile:

nano Dockerfile

And use following content inside it:

FROM debian
RUN apt update && apt install mariadb-server -y
RUN sed -i 's/bind-address/bind-address = #/i' /etc/mysql/mariadb.conf.d/50-server.cnf
RUN mkdir /mysql_scripts
COPY mySqlScript.sql /mysql_scripts/
RUN /etc/init.d/mysql start && mysql -uroot --password="" -e "source /mysql_scripts/mySqlScript.sql"
CMD /etc/init.d/mysql start && tail -f /dev/null

MySQL initialization script

Finally, create your database initialization script:

nano mySqlScript.sql

Use following code, changing “mediauser” and “mediapassword” with your preferred credentials:

CREATE USER mediauser@'%' IDENTIFIED BY 'mediapassword';
GRANT ALL PRIVILEGES ON my_wiki.* TO mediauser@'%';
flush privileges;

Service Creation and Initialization

With previous files ready to be used, you will be able to install and have it up only with following command:

docker-compose up -d

This process will require a while to download required images and install / configure MariaDB.

Once your Raspberry PI prompts you for installation finished, you can go to your favourite browser to configure your mediawiki installation. Browse url http://<<yourRaspberryIpAddress>>:8080 (in my case, My local Raspberry PI IP address il

Raspberry PI Mediawiki start first setup

First page notifies you that settings file have not been found. Following steps will create it. Click on “set up the wiki” link. Next page will ask you for your preferred language;

Raspberry PI Mediawiki language setup

Choose it and click Continue. Next page will warn you that some environmental checks will be performed:

Raspberry PI Mediawiki check warning

Scrolling down, you should see a green row reporting: “The environment has been checked. You can install MediaWiki.”. Scroll to bottom and click “Continue”. Next page will requiredatabase configuration:

Raspberry PI Mediawiki database connection

Scroll down to white fields. Leave MariaDB in database type and use following for other fields (changing mediauser and mediapassword with your ones configured in MySQL initialization script). Note that you have to change Database Host from default “localhost” to “database:3306”:

Raspberry PI Mediawiki database configuration

Scroll down and click continue. Next screen will make you able to use same user/password configured for database connection also for web access:

Raspberry PI Mediawiki web user configuration

You can noth change and make your configuration more secure (but you need to define a new database user) or keep default and click continue. Next page will ask you the name for your mediawiki page and administration account.

Raspberry PI Mediawiki web preferences

Use your favourite ones (remmber to use a strong password). To complete installation, scroll down and select “I’m bored already, just install the wiki.” option, then click Continue. Finally, a confirmation for installation completion will be asked to you:

Raspberry PI Mediawiki web installation confirmation

Click Continue to complete. Next screen will confirm that installation is complete:

Raspberry PI Mediawiki web installation complete

Click continue. With next page, a popup will open giving you a download for a file named “LocalSettings.php”:

Raspberry PI Mediawiki download localsettings

Download it locally and copy to your mediawiki folder (docker-compose folder) in your Raspberry PI. From terminal, shut down mediawiki service:

 docker-compose down

Edit docker-compose.yml file, uncommenting following line:

  - ./LocalSettings.php:/var/www/html/LocalSettings.php

This will allow mediawiki container to import LocalSettings.php file in apache directory. Finally, our new folder will contain following files:


Start again with docker-compose;

docker-compose up -d

And go back to your browser, refreshing http://<<yourRaspberryIpAddress>>:8080 page. You will find now your Mediawiki page ready:

Raspberry PI Mediawiki home

Final Operations

Once finished, a good security practice is entering your database container and changing DB root password.


How useful was this post?

Click on a star to rate it anonymously!

Average rating 5 / 5. Vote count: 7

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?


  1. NICE!
    I had to make 1 adjustment:
    Thanks for the really easy to follow tutorial

    COMPOSE_HTTP_TIMEOUT=200 sudo docker-compose up -d

    because of an error:
    ERROR: for mediawiki_mediawiki_1 UnixHTTPConnectionPool(host=’localhost’, port=None): Read timed out. (read timeout=60)

    -> COMPOSE_HTTP_TIMEOUT=200 sudo docker-compose up -d
    ERROR: No such container: c4678ed7f14288eb301415a28283d63e45f5e92a3e36af20dcf1cda491cb04c2
    -> FIX:
    sudo docker stop c4678ed7f14288eb301415a28283d63e45f5e92a3e36af20dcf1cda491cb04c2
    pi@raspberrypi:~/mediawiki $ sudo docker rm -f c4678ed7f14288eb301415a28283d63e45f5e92a3e36af20dcf1cda491cb04c2
    pi@raspberrypi:~/mediawiki $ sudo docker-compose up -d
    mediawiki_database_1 is up-to-date

  2. Final adjustment.
    The downoaded LocalSettings.php:
    – not only remove the hash but also make sure to line out the “-” at the same location as the other earlier line 😉
    – mediawiki-www:/var/www/html
    – ./LocalSettings.php:/var/www/html/LocalSettings.php
    Otherwise the last – will be not at the right position (Yml)


Leave a Reply

Your email address will not be published. Required fields are marked *

I accept the Privacy Policy