This guide walks through deploying MediaWiki in a Docker environment to create a shared wiki platform accessible to team members. Whether you're working within a local network or using a cloud server, Docker simplifies the installation process significantly.
Prerequisites
Before starting, ensure you have basic familiarity with MySQL database operations and PHP fundamentals. These skills will help you troubleshoot and customize your wiki installation effectively.
Server Setup
For this deployment, an Ubuntu 16.04 server was used. The first step involves establishing an SSH connection to your server:
ssh username@your_server_ip
Installing Docker
Install Docker Community Edition (CE) on your Ubuntu server. Detailed installation instructions are widely available online. After installation, verify Docker is running:
docker --version
docker ps
Pulling Required Images
Retrieve the MySQL and MediaWiki images from Docker Hub. The following versions were selected for this deployment:
docker pull mysql:5.7
docker pull mediawiki:stable
Deploying MySQL Container
Create and run the MySQL container with appropriate configuration:
docker run --name mysql_wiki -p 3307:3306 -e MYSQL_ROOT_PASSWORD=your_secure_password -d mysql:5.7
Parameters explained:
--name: Assigns a friendly name to the container for easy reference-p 3307:3306: Maps container port 3306 to host port 3307 for external access-e MYSQL_ROOT_PASSWORD: Sets the root password for MySQL
Configuring Remote Access
Access the MySQL container to configure remote connectivity:
docker exec -it mysql_wiki bash
Once inside the container, log into MySQL:
mysql -u root -p
Switch to the mysql database:
use mysql;
Create a root account that permits remote connections:
grant all privileges on *.* to 'root'@'%' identified by 'your_password';
flush privileges;
Verify the configuration:
SELECT User,Host FROM mysql.user;
You should see two root accounts—one for localhost and one for remote access (%).
Firewall Configuration
Open port 3307 in your server's firewall to allow external MySQL connections. On Alibaba Cloud or similar providers, add a custom TCP rule for port 3307.
Testing Remote Connection
From your local machine, test the MySQL connection:
mysql -h your_server_ip -P 3307 -u root -p
A successful connection confirms the database environment is properly configured.
Deploying MediaWiki Container
docker run --name mywiki --link mysql_wiki:mysql -p 999:80 -d mediawiki:stable
The --link parameter creates a network connection between the MediaWiki container and the MySQL container, enabling database communication.
Remember to open port 999 in your firewall to allow HTTP access.
Initial Wiki Setup
Access the wiki through your browser:
http://your_server_ip:999
Click "Set up the wiki" to begin the installation wizard. Select your preferred language, then proceed through the environment checks—Docker has already configured the necessary dependencies.
Database Connection
When prompted for database settings:
- Database host: your_server_ip
- Port: 3307
- Username: root
- Passsword: your_mysql_password
Complete the remaining setup steps according to the wizard prompts.
Finalizing Installation
Download the generated LocalSettings.php file and upload it to your server. Transfer the file into the MediaWiki container:
docker cp LocalSettings.php mywiki:/var/www/html/
Refresh your browser—you should now see your wiki homepage.
Customization and Configuration
Modifying the Logo
Upload a 135×135 pixel PNG image to the container's assets directory. Update the LocalSettings.php file to reference your custom logo:
$wgLogo = "$wgStylePath/assets/your-logo.png";
Enabling User Registration
Require login for editing while allowing visitors to read:
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createaccount'] = true;
Enabling File Uploads
Activate the file upload feature in LocalSettings.php:
$wgEnableUploads = true;
Increasing Upload Size Limits
By default, MediaWiki restricts uploads to 2MB. To increase this limit, access the PHP configuration within the container:
docker exec -it mywiki bash
php --ini
Locate the PHP configuration directory and create a php.ini file:
cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
Edit the php.ini file to modify upload parameters:
upload_max_filesize = 1024M
post_max_size = 1024M
Add corresponding settings to LocalSettings.php:
$wgMaxUploadSize = 1073741824;
$wgMaxPhpUploadSize = 1073741824;
Restart the Apache web server within the container:
service apache2 restart
If the container stops, restart it:
docker start mywiki
Your wiki now supports file uploads up to 1GB in size.