Install MediaWiki using Docker and Docker Compose
MediaWiki is a free and open-source wiki software originally developed for use on Wikipedia. It is now widely used by various organizations and communities to create and manage collaborative content.
MediaWiki is written in PHP and uses a backend database to store its content. Its robust and flexible platform supports a wide range of extensions and configurations, making it suitable for small personal wikis as well as large enterprise knowledge management systems.
Key Features of MediaWiki
- Collaborative Editing: Multiple users can contribute and edit content, with a history of changes maintained for each page.
- Version Control: Every edit is tracked, allowing users to view previous versions, compare changes, and revert to earlier versions if needed.
- Rich Content Formatting: MediaWiki supports extensive formatting, including tables, images, and links, through a simplified markup language called Wikitext.
- User Management and Permissions: MediaWiki offers robust user management features, including different permission levels, allowing admins to control who can view, edit, or manage content.
- Extensions and Plugins: MediaWiki's functionality can be extended with a wide array of plugins and extensions, from adding custom authentication methods to integrating with other software.
- Search and Navigation: Built-in search functionality and navigational aids make it easy for users to find and explore content.
- Template System: MediaWiki includes a powerful template system that allows for the reuse of content and formatting across multiple pages.
- Multilingual Support: MediaWiki supports multiple languages, making it a great tool for global communities or organizations.
- API Access: MediaWiki includes an API that allows developers to interact programmatically with the content, making it suitable for integration with other systems.
Installing MediaWiki Using Docker and Docker Compose
Here’s a step-by-step guide to installing MediaWiki using Docker and Docker Compose:
Create a Directory for MediaWiki
First, create a directory where you’ll store the Docker Compose configuration and related data.
mkdir mediawiki-docker
cd mediawiki-docker
Create a docker-compose.yml
File
Create a docker-compose.yml
file with the following content:
version: '3.1'
services:
mediawiki:
image: mediawiki:latest
container_name: mediawiki
ports:
- "8080:80"
environment:
MEDIAWIKI_DB_HOST: db
MEDIAWIKI_DB_USER: mediawiki
MEDIAWIKI_DB_PASSWORD: mediawiki_pass
MEDIAWIKI_DB_NAME: mediawiki
depends_on:
- db
volumes:
- ./mediawiki_data:/var/www/html/images
db:
image: mysql:5.7
container_name: mediawiki_db
environment:
MYSQL_ROOT_PASSWORD: root_pass
MYSQL_DATABASE: mediawiki
MYSQL_USER: mediawiki
MYSQL_PASSWORD: mediawiki_pass
volumes:
- ./db_data:/var/lib/mysql
Configure Environment Variables
Replace the placeholder passwords (root_pass
, mediawiki_pass
) with secure passwords of your choice.
Start the Containers
Run the following command to start MediaWiki and its MySQL database:
docker-compose up -d
This command will download the necessary Docker images, create the containers, and start the MediaWiki service.
Access MediaWiki
Once the containers are running, you can access MediaWiki by navigating to http://localhost:8080
in your web browser.
Complete the Installation
- Database Configuration: When you first access the site, you’ll be prompted to complete the setup. Enter the database name (
mediawiki
), the database username (mediawiki
), and the password you configured in thedocker-compose.yml
file. - Site Configuration: You’ll then be asked to configure your site name, admin account, and other settings.
Restart MediaWiki: Restart the MediaWiki container to apply the settings.
docker-compose restart mediawiki
Download LocalSettings.php
: After completing the setup, you’ll be asked to download a LocalSettings.php
file. Upload this file to the mediawiki_data
directory in your Docker setup.
cp /path/to/LocalSettings.php ./mediawiki_data/
Access Your MediaWiki Installation
Once everything is set up, you can start using MediaWiki by navigating to http://localhost:8080
. You’ll now have a fully functional wiki that can be customized and expanded with extensions and templates.
Managing Your Containers
To restart the containers:
docker-compose restart
To view logs:
docker-compose logs -f
To stop the containers:
docker-compose down
Conclusion
This guide provides a straightforward method to install and configure MediaWiki using Docker and Docker Compose.
With this setup, you can quickly deploy a powerful and flexible wiki platform on your local machine or server, making it an ideal solution for creating and managing collaborative content within your organization or community.