How to setup a Wiki easily

Requirements:

  • Docker
  • A server with yourdomain.com already pointing at it
  • 5-10 minutes

Everybody knows Wikipedia, but few know that Wikipedia is actually running on open source software. The Wikimedia Foundation develops his own wiki engine that they use for all their projects, including Wikipedia. This wiki engine is named MediaWiki. That being said now, that's what we are going to use here to set up our own wiki :-)

First of all, you need a server with Docker installed on it. So obviously I would recommend a Linux server for that matter. As an example, Digital Ocean proposes an image with Docker preinstalled on Ubuntu so with a couple of clicks you can get a Droplet setup with Ubuntu and Docker ready-to-go. AWS and others have probably such equivalent images in their inventory too, I think.

If you have a look at the Docker hub, you will be able to find this Docker image in particular: https://hub.docker.com//mediawiki/ This is the official docker image from the Wikimedia Foundation itself. This is definitely what we want to use.

Considering your wiki project, you will decide if you need to use a MySQL-like database or use the default embedded SQLite. In my case I decided to use SQLite, I knew that the community, I was making the wiki for, was small hence a simple SQLite is pretty sufficient.

So to deploy your MediaWiki with Docker, there's a little trick. First, create a folder wherever you want to store all the files related to the wiki. Then start the wiki, visit your wiki at http://yourdomain.com, do the setup, and download the LocalSettings.php generated for you. Finally, restart a new container with this LocalSettings.php and you are ready to go.

Here is the code I used:

# Create the folder
mkdir wiki; cd wiki
# Start the wiki setup
docker run --name my-wiki -d -v /wiki/data:/var/www/data -v /wiki/images:/var/www/html/images -v /wiki/extensions:/var/www/html/extensions  mediawiki

After it's setup and LocalSettings.php properly uploaded into my wiki folder.

docker stop my-wiki && docker rm my-wiki
echo docker run --name my-wiki -d -v /wiki/data:/var/www/data -v /wiki/images:/var/www/html/images -v /wiki/extensions:/var/www/html/extensions -v /wiki/LocalSettings.php:/var/www/html/LocalSettings.php --restart=always mediawiki > start.sh
chmod +x start.sh 
./start.sh

The command to start the container is kinda long so I suggest to save it in a start.sh in order to avoid to type it ever again.

VoilĂ  then just visit yourdomain.com and your wiki is ready to use.

Show Comments