Deploy Your Own MediaWiki Wiki
Steps
Create Docker Compose File
Copy the following contents into a docker-compose.yml
file
version: '3.4'
services:
mediawiki:
container_name: wiki
image: mediawiki
restart: always
depends_on:
- db
ports:
- 80:80
volumes:
- mediawiki-images:/var/www/html/images
# After initial setup, download LocalSettings.php to the same directory as
# this YAML file and uncomment the following line and use compose to restart
# the mediawiki service
#- ./LocalSettings.php:/var/www/html/LocalSettings.php:ro
db:
image: mariadb
container_name: db
restart: always
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
test: mysqladmin status -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
start_period: 5s
interval: 5s
timeout: 5s
retries: 55
environment:
# @see https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php
MYSQL_RANDOM_ROOT_PASSWORD: 1
MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
volumes:
mysql-data:
driver: local
mediawiki-images:
driver: local
Create Environment File
Create a .env
file at the same directory level as the docker-compose.yml
file with the following content, being sure to fill in a value for the database password.
COMPOSE_PROJECT_NAME=mediawiki
# Database connection details
DB_USER="mediawiki"
DB_PASSWORD=""
DB_NAME="mediawiki"
DB_PASSWORD
, I would recommend something long, but alphanumeric only to prevent any kind of issues with special chars.
Docker Compose Up
Start the containers with:
docker-compose up
Browser Installation Forms
Navigate to your wiki server's IP address or hostname and complete the installation guide by clicking on the link.
The hardest part of the guide is filling in the database connection details. For the host you need to specify:
db://localhost
The database username, password, and name are all from the settings in the .env
file you created earlier.
LocalSettings File
When you finish, you will automatically download a LocalSettings.php file.
Copy this file to the same directory as your docker-compose.yml file, before then uncommenting the LocalSettings.php volume line in the docker-compose.yml file.
version: '3.4'
services:
mediawiki:
container_name: wiki
image: mediawiki
restart: always
depends_on:
- db
ports:
- 80:80
volumes:
- mediawiki-images:/var/www/html/images
# After initial setup, download LocalSettings.php to the same directory as
# this YAML file and uncomment the following line and use compose to restart
# the mediawiki service
- ./LocalSettings.php:/var/www/html/LocalSettings.php:ro
db:
image: mariadb
container_name: db
restart: always
volumes:
- mysql-data:/var/lib/mysql
healthcheck:
test: mysqladmin status -h 127.0.0.1 -u $$MYSQL_USER --password=$$MYSQL_PASSWORD
start_period: 5s
interval: 5s
timeout: 5s
retries: 55
environment:
# @see https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php
MYSQL_RANDOM_ROOT_PASSWORD: 1
MYSQL_DATABASE: ${DB_NAME}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_PASSWORD}
volumes:
mysql-data:
driver: local
mediawiki-images:
driver: local
Restart The Containers
Now stop and start your containers with:
docker-compose down
docker-compose up
Check Out Your Wiki
Now navigate to your wiki's IP or hostname in your browser and you should see:
Click the login link to get to the login page:
Once you have logged in using the username and password you filled in during the installation guide, you should see:
First published: 14th October 2018