Jump to content

Mediawiki Setting Up Guide

From MediawikiCIT

MediaWiki Docker Setup Guide

This guide walks you through setting up MediaWiki using Docker and Dockhand. Follow the steps carefully, as specific paths are required for extensions and configuration to work correctly.

Getting Started

Before proceeding, make sure you have access to a Linux server or local machine with sudo privileges.

Installation Steps

1. Install Docker and Docker Compose

Ensure that Docker and Docker Compose are installed on your system. These tools are required to run MediaWiki and its supporting services in containers.

2. Set Up Dockhand

Dockhand provides a simple web-based interface for managing Docker stacks.

Run the following command in your terminal:

# Use matching paths with DATA_DIR 
docker run -d \
  --name dockhand \
  -p 3000:3000 \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /opt/dockhand:/opt/dockhand \
  -e DATA_DIR=/opt/dockhand \
  fnsys/dockhand:latest

Once the container is running, open your browser and go to:

http://localhost:3000

You should now see the Dockhand web interface.

3. Create the MediaWiki Stack Directory

Next, create a dedicated directory on the Docker host for your MediaWiki stack.

This location is important because it will store your configuration files and extensions.

Run the following commands:

sudo mkdir -p /opt/stacks/mediawiki
sudo mkdir -p /opt/stacks/mediawiki/extensions
cd /opt/stacks/mediawiki

4. Create the Docker Compose File

Inside the /opt/stacks/mediawiki directory, create a Docker Compose file:

touch docker-compose.yml

To edit the file, run:

nano docker-compose.yml

Paste the following configuration inside the file:

services:
  mediawiki:
    image: mediawiki
    container_name: mediawiki
    restart: always
    ports:
      - "${MEDIAWIKI_PORT}:80"
    depends_on:
      - database
    volumes:
      - 230912_images:/var/www/html/images
      - /opt/stacks/mediawiki/extensions:/var/www/html/extensions
      # - /opt/stacks/mediawiki/LocalSettings.php:/var/www/html/LocalSettings.php:ro

  database:
    image: mariadb
    container_name: mediawiki-db
    restart: always
    environment:
      MYSQL_DATABASE: "${MYSQL_DATABASE}"
      MYSQL_USER: "${MYSQL_USER}"
      MYSQL_PASSWORD: "${MYSQL_PASSWORD}"
      MYSQL_ROOT_PASSWORD: "${MYSQL_ROOT_PASSWORD}"
    volumes:
      - 230912_db:/var/lib/mysql

volumes:
  230912_images:
  230912_db:

Save and exit the file.

5. Create the Environment File (.env)

The .env file stores your environment variables such as database credentials and port configuration.

Make sure you are inside:

/opt/stacks/mediawiki

Create the file:

sudo touch .env

Edit the file:

nano .env

Paste the following:

# MediaWiki
MEDIAWIKI_PORT=8595

# Database
MYSQL_DATABASE=sampleName
MYSQL_USER=sampleUser
MYSQL_PASSWORD=samplePassword
MYSQL_ROOT_PASSWORD=sampleRootPass

Save and exit.

6. Start the MediaWiki Stack

To build and start the containers, run:

docker compose up -d

Once the containers are running, open your browser and go to:

http://localhost:8595

You should now see the MediaWiki setup page.