Unlock the power of your own personal knowledge base by learning how to seamlessly self host MediaWiki on your server. This comprehensive guide will walk you through deploying MediaWiki using Portainer Stacks (or Docker Compose), ensuring a robust, maintainable, and highly efficient Docker wiki solution. Whether for documentation, project tracking, or an internal knowledge hub, discover how easy it is to bring your collaborative platform to life, containerized and ready for action.
Why Self-Host MediaWiki? Your Ultimate Knowledge Base Solution
MediaWiki is a powerful, open-source software that empowers you to create and operate your very own wiki. It’s the ideal platform for building comprehensive `knowledge base` systems, technical documentation, tracking maker projects, or establishing internal informational hubs. The significant advantage of this method lies in its containerized nature, ensuring MediaWiki is incredibly easy to maintain and runs cleanly isolated from other services on your system.
This setup is perfectly suited for a variety of environments, from humble `home lab` servers and Raspberry Pi deployments to more robust professional `self hosting` infrastructures, offering flexibility and scalability for your projects.
Essential Prerequisites for a Robust MediaWiki Setup
Domain, HTTPS, and Secure Access
For optimal accessibility and security, we strongly recommend using a dedicated domain or a dynamic DNS (DynDNS) service. This allows your wiki to be reached via a human-readable address and, crucially, secured with HTTPS. Alternatively, you can always access MediaWiki directly via your server’s IP address, though this is less secure and user-friendly for public-facing instances.
For secure communication over the internet, deploying an SSL certificate is paramount. You can easily achieve this using services like Let’s Encrypt, or by securing access via Cloudflare. Always remember that SSL is an absolute necessity when making your services publicly accessible.
Pro Tip: Consider integrating a `reverse proxy` like Nginx Proxy Manager or Traefik early in your `self hosting` journey. This centralizes SSL management, simplifies port forwarding, and enhances security for all your `Docker wiki` services, providing a single entry point for external traffic.
Understanding the Container Architecture
In this robust setup, two key containers will be deployed: the MediaWiki web application itself and a MariaDB database. Both containers are configured to store their critical data persistently in Docker Volumes. This ensures that all your content, images, and database information remain intact and accessible, even after container restarts or system updates.
Step-by-Step MediaWiki Installation with Portainer Stacks
Creating Your MediaWiki Stack in Portainer
Begin by navigating to your Portainer instance and creating a new stack. Assign it a descriptive name that reflects its purpose, such as “mediawiki-wiki”.
The Docker Compose Configuration Explained
Once you’ve named your stack, paste the following `docker-compose` code into the web editor. Before deploying, make sure to customize the paths for persistent data, adjust the exposed ports, and crucially, configure your MariaDB database credentials for enhanced security.
version: '3'
services:
mediawiki:
image: mediawiki
restart: always
ports:
- 8080:80
links:
- database
volumes:
- images:/var/www/html/images
# After initial setup, uncomment and bind LocalSettings.php here:
# - /path/to/your/LocalSettings.php:/var/www/html/LocalSettings.php
database:
image: mariadb
restart: always
environment:
MYSQL_DATABASE: my_wiki
MYSQL_USER: wikiuser
MYSQL_PASSWORD: example
MYSQL_RANDOM_ROOT_PASSWORD: 'yes' # Set to 'no' and define MYSQL_ROOT_PASSWORD for specific root control
volumes:
- db:/var/lib/mysql
volumes:
images:
db:
This configuration launches MediaWiki, accessible on host port `8080`, and connects it to a dedicated MariaDB database container. The `images` and `db` volumes are pivotal for ensuring your uploaded media, files, and all database content are permanently stored and persist across container lifecycle events.
Remember to adjust `8080` to your desired host port if it’s already in use, and **replace `my_wiki`, `wikiuser`, and `example` with your unique, secure database credentials** before deployment.
Deploying and Initial Access
After making your necessary adjustments, click “Deploy Stack”. Once the stack has successfully deployed and both containers are running, you can access your brand-new MediaWiki instance in your web browser by navigating to `http://:8080` (replacing “ with your server’s actual IP address or domain).
Configuring Your MediaWiki Instance
Navigating the MediaWiki Setup Wizard
The first time you access your MediaWiki URL, you’ll be guided through an intuitive installation process. Here, you’ll provide the connection details for your MariaDB database. Crucially, when prompted for the database server, use the Docker service name `database` (not `localhost`), as both containers reside within the same Docker network.
Following the database configuration, you’ll proceed to set up further essential details, including the name of your wiki and the administrative account credentials. Choose a strong password for your admin account.
Finally, you’ll be asked to select your preferred design theme and any extensions you wish to install immediately. Don’t worry, you can always add or modify these later to expand your `Docker wiki`’s functionality.
Integrating LocalSettings.php for Persistence
Upon completing the initial setup, MediaWiki will prompt you to download the `LocalSettings.php` file. This file contains all your specific configuration settings. To ensure these settings persist, you need to integrate this file into your MediaWiki container. Copy the downloaded `LocalSettings.php` into a dedicated folder on your host machine (e.g., `/opt/mediawiki/config/LocalSettings.php`). Then, uncomment the commented line in your Portainer stack (or `docker-compose.yml`), adjust the path to reflect your host’s file location, and update the stack.
With this final step, your own `MediaWiki` is successfully set up and ready for you to fill it with valuable information!
Maintaining Your Self-Hosted MediaWiki: Best Practices
Backup Strategy for Your Docker Wiki
Regular backups are non-negotiable for any `self hosting` environment. Ensure you routinely back up both the `db` volume (containing your MariaDB data) and the `images` volume (where all your uploaded files and wiki assets reside). Consider automated backup solutions or simple scripts that copy these volumes to a secure offsite location.
Seamless Updates for MediaWiki Containers
Updating MediaWiki is straightforward when running it in Docker. To update, simply pull the latest `mediawiki` Docker image (`docker pull mediawiki`), and then restart your MediaWiki container. This will bring your wiki up to the newest version with minimal downtime.
Advanced Tip: For automated updates, consider tools like Watchtower. However, always test major `MediaWiki` updates in a staging environment first, especially if you have custom extensions or modifications, to avoid unexpected downtime or breaking changes in your production `knowledge base`.
Enhancing Security for Your Self-Hosted Knowledge Base
Security is an ongoing process. Always use strong, unique passwords for all your accounts, especially the MediaWiki administrator and MariaDB user. As mentioned, operating your wiki behind a `reverse proxy` with HTTPS enabled is crucial for securing data in transit. Additionally, regularly review your server’s firewall rules and apply host operating system security updates diligently.
In diesem Beitrag zeige ich euch, wie ihr MediaWiki mithilfe von Portainer als Stack (oder mit docker-compose) auf eurem Server installieren könnt. MediaWiki ist eine leistungsfähige Open-Source-Software, die es euch ermöglicht, eine eigene Wiki-Seite zu erstellen und zu betreiben. Ideal für Wissensdatenbanken, Dokumentationen, Maker-Projekte oder interne Wissensplattformen.
Der Vorteil dieser Methode: MediaWiki läuft containerisiert, ist leicht wartbar und kann sauber von anderen Diensten getrennt betrieben werden. Dieses Setup eignet sich sowohl für Heimserver, Raspberry-Pi-Server als auch für professionelle Self-Hosting-Umgebungen.
Infos
Auch hier empfiehlt es sich, eine eigene Domain oder DynDNS zu verwenden, damit euer Wiki über HTTPS erreichbar ist. Alternativ könnt ihr MediaWiki auch über die IP-Adresse eures Servers ansteuern.
Für eine sichere Kommunikation über das Internet empfiehlt sich der Einsatz eines SSL-Zertifikats. Wie bei anderen Diensten könnt ihr hierfür Let’s Encrypt verwenden oder den Zugang über Cloudflare absichern. Denkt daran, dass SSL immer dann erforderlich ist, wenn ihr eure Dienste öffentlich bereitstellt.
Hinweis zur Architektur: In diesem Setup laufen zwei Container: MediaWiki (Webanwendung) und MariaDB (Datenbank). Beide speichern ihre Daten persistent in Docker-Volumes, damit Inhalte und Datenbank auch nach einem Neustart oder Update erhalten bleiben.
Installation als Stack
Erstellt einen neuen Stack in eurer Portainer-Instanz und benennt ihn.
Fügt dann folgenden Code in den Web-Editor ein, passt die Pfade für die persistenten Daten, die Ports und die MariaDB-Daten an und klickt anschließend auf “Deploy Stack”:
version: '3'
services:
mediawiki:
image: mediawiki
restart: always
ports:
- 8080:80
links:
- database
volumes:
- images:/var/www/html/images
# Nach dem Setup wird hier die LocalSettings.php eingebunden
database:
image: mariadb
restart: always
environment:
MYSQL_DATABASE: my_wiki
MYSQL_USER: wikiuser
MYSQL_PASSWORD: example
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
volumes:
- db:/var/lib/mysql
volumes:
images:
db:
Dieses Setup startet MediaWiki auf Port 8080 und verwendet MariaDB als Datenbank. Die Volumes images und db sorgen dafür, dass Bilder, Uploads und Datenbankinhalte dauerhaft gespeichert werden.
Sobald der Stack deployed wurde, könnt ihr MediaWiki im Browser unter http://:8080 aufrufen.
Wenn ihr die Seite zum ersten Mal aufruft, werdet ihr durch den Installationsprozess von MediaWiki geführt.
Hier gebt ihr die Verbindungsdaten zur MariaDB-Datenbank an. Als Datenbankserver verwendet ihr in Docker den Servicenamen database (nicht localhost), da beide Container im selben Docker-Netzwerk laufen.
Danach folgen noch weitere Einstellungen wie der Name des Wikis und das Administratorkonto.
Außerdem werdet ihr noch gefragt, welches Design verwendet werden soll und welche Erweiterungen ihr installieren möchtet. Diese können später jederzeit ergänzt werden.
Nachdem der Ersteinrichtungsprozess abgeschlossen ist, müsst ihr die LocalSettings.php herunterladen und in den MediaWiki-Container einbinden. Kopiert die Datei in den entsprechenden Ordner, kommentiert die Zeile im Stack aus, passt den Pfad an und aktualisiert den Stack.
Damit habt ihr euer eigenes MediaWiki erfolgreich aufgesetzt und könnt es mit euren Informationen füllen.
Wichtige Hinweise für den Betrieb
- Backups: Sichert regelmäßig das Datenbank-Volume db und das Upload-Volume images.
- Updates: MediaWiki wird durch Aktualisieren des Docker-Images aktualisiert. Danach Container neu starten.
- Sicherheit: Verwendet sichere Passwörter und betreibt das Wiki hinter einem Reverse Proxy mit HTTPS.
FAQ
Q1: Why should I choose MediaWiki for my self-hosted knowledge base?
A1: MediaWiki is renowned for its scalability, robust feature set, and extensive community support. It’s highly customizable with a vast array of extensions, making it ideal for everything from personal notes to large organizational wikis. Its open-source nature means you have full control and can adapt it to specific needs, unlike SaaS alternatives, making it a prime candidate for `self hosting` a `knowledge base`.
Q2: How can I ensure my self-hosted MediaWiki instance is secure?
A2: Security is paramount. Always use strong, unique passwords for your MariaDB and MediaWiki admin accounts. Deploy your wiki behind a `reverse proxy` (like Nginx, Caddy, or Traefik) configured with HTTPS using a valid SSL certificate (e.g., Let’s Encrypt). Regularly update your Docker images, apply host server security patches, and implement a robust firewall to protect your `Docker wiki`.
Q3: Can I update MediaWiki without losing data?
A3: Yes, one of the key benefits of this containerized setup is data persistence. Since your wiki data and database are stored in separate Docker volumes (`images` and `db`), updating MediaWiki simply involves pulling the latest Docker image and restarting the container. Your content will remain safe. However, always perform regular backups before major updates as a best practice in `self hosting`.

