Mediawiki Setting Up Guide: Difference between revisions
BabiSender (talk | contribs) |
BabiSender (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
<div style="font-size: 100%;"> | <div style="font-size: 100%;"> | ||
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. | 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. | ||
Revision as of 05:53, 12 February 2026
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
This file will later contain the service definitions for MediaWiki, the database, and related components.
5. Edit the Docker Compose Configuration
Now you'll configure the services that will run your MediaWiki installation.
Open the file for editing:
nano docker-compose.yml
Paste the following configuration into 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
# EXTENSIONS: Mounts host folder to container
- /opt/stacks/mediawiki/extensions:/var/www/html/extensions
# CONFIG: Uncomment AFTER generating LocalSettings.php
# - /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 (press Ctrl + O, then enter, then Ctrl + X).
6. Create the Environment Variables File
The .env file stores sensitive information like passwords and port numbers. This keeps them separate from your main configuration.
While still in the /opt/stacks/mediawiki directory, create the environment file:
sudo touch .env
Open it for editing:
sudo nano .env
Paste the following configuration:
# MediaWiki
MEDIAWIKI_PORT=8595
# Database
DB_IMAGE=mariadb
DB_CONTAINER_NAME=mediawiki-db
MYSQL_DATABASE=my_wiki
MYSQL_USER=wikiuser
MYSQL_PASSWORD=your_secure_password
MYSQL_ROOT_PASSWORD=your_root_password
Note: Change the password values to something secure. Make sure DB_CONTAINER_NAME matches the container name in docker-compose.yml (in this case: mediawiki-db).
Save and exit.
7. Start the MediaWiki Containers
With your configuration files ready, start the Docker containers:
docker compose up -d
The -d flag runs the containers in the background (detached mode).
Initial MediaWiki Setup
8. Complete the Web Installation Wizard
Open your web browser and navigate to:
http://localhost:8595
Note: If you're setting this up on a remote server, replace localhost with your server's IP address.
Follow the on-screen setup wizard. When you reach the Database Settings page, enter these values:
- Database host:
mediawiki-db - Database name:
my_wiki - Database username:
wikiuser - Database password:
your_secure_password
Note: These values should match what you set in the .env file in Step 6.
Complete the remaining setup steps, then download the LocalSettings.php file to your computer when prompted.
9. Move LocalSettings.php to the Server
Copy the downloaded configuration file from your local machine to the MediaWiki directory on your server:
sudo cp ~/Downloads/LocalSettings.php /opt/stacks/mediawiki/
Note: Adjust the path ~/Downloads/ if your file was saved to a different location.
Configuring Extensions
10. Extract Default Extensions (The "Magic Command")
MediaWiki comes with built-in extensions that need to be extracted to your host directory.
Step A: Extract Extensions
Run this command to copy all default extensions from the container to your host:
docker run --rm mediawiki tar -cC /var/www/html/extensions . | sudo tar -xC /opt/stacks/mediawiki/extensions
Step B: Fix File Permissions
Set the correct ownership and permissions so MediaWiki can use these extensions:
sudo chown -R 33:33 /opt/stacks/mediawiki/extensions
sudo chmod -R 755 /opt/stacks/mediawiki/extensions
Note: User ID 33 is the web server user (www-data) inside the container.
Step C: Add External Extensions (Optional)
To add extensions not included by default, download them to the extensions folder. For example, to add the Mermaid diagram extension:
cd /opt/stacks/mediawiki/extensions
git clone https://github.com/SemanticMediaWiki/Mermaid.git Mermaid
Note: Skip this step if you don't need the Mermaid extension or already have it installed.
To add the Lockdown extension (required for private namespaces):
cd /opt/stacks/mediawiki/extensions
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Lockdown.git
sudo chown -R 33:33 Lockdown
Activating LocalSettings.php
11. Enable the LocalSettings Mount
Now that LocalSettings.php exists on your server, you need to mount it into the container.
Open the Docker Compose file again:
nano docker-compose.yml
Find this commented line in the mediawiki service section:
# - /opt/stacks/mediawiki/LocalSettings.php:/var/www/html/LocalSettings.php:ro
Remove the # to uncomment it:
- /opt/stacks/mediawiki/LocalSettings.php:/var/www/html/LocalSettings.php:ro
Save and exit.
12. Customize LocalSettings.php - Basic Configuration
Open the LocalSettings file for editing:
sudo nano /opt/stacks/mediawiki/LocalSettings.php
A. Set Your Custom Domain
Find the line that starts with $wgServer and update it with your actual domain or IP address:
$wgServer = "https://mediawiki.yourdomain.com";
Note: Use http:// if you haven't set up SSL/HTTPS yet. For local testing, use http://localhost:8595.
B. Add Basic Extensions Configuration
Scroll to the very bottom of the file and paste this configuration block:
/*-------------------------------------------
CUSTOM PERMISSIONS & EXTENSIONS
----------------------------------------- */
// 1. SECURITY: Prevent anonymous editing and account creation
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createaccount'] = false;
// 2. BUNDLED EXTENSIONS
wfLoadExtension( 'WikiEditor' );
wfLoadExtension( 'VisualEditor' );
wfLoadExtension( 'CodeEditor' );
wfLoadExtension( 'SyntaxHighlight_GeSHi' ); # REQUIRED for Code Blocks
wfLoadExtension( 'Cite' );
wfLoadExtension( 'InputBox' );
wfLoadExtension( 'Scribunto' );
wfLoadExtension( 'AbuseFilter' );
wfLoadExtension( 'Gadgets' );
wfLoadExtension( 'ParserFunctions' );
// wfLoadExtension( 'Interwiki' ); # Moved to core in MediaWiki 1.44.0
// 3. EXTERNAL EXTENSIONS
wfLoadExtension( 'Mermaid' );
// 4. VISUALEDITOR CONFIGURATION
$wgDefaultUserOptions['visualeditor-enable'] = 1;
$wgVisualEditorParsoidForwardCookies = true;
// 5. LUA CONFIGURATION (Required for Scribunto)
$wgScribuntoDefaultEngine = 'luastandalone';
// 6. LOGIN SECURITY: Throttle login attempts
$wgRateLimits['user']['login'] = [ 5, 60 ]; // 5 attempts per minute
$wgRateLimits['ip']['login'] = [ 20, 300 ]; // 20 attempts per 5 minutes
Note: The Interwiki extension is commented out because its functionality was moved to MediaWiki core in version 1.44.0. If you're using an older version, uncomment this line.
Save and exit.
Finalizing the Basic Installation
13. Update the Database Schema
After enabling extensions, update the MediaWiki database to recognize them:
docker exec -it mediawiki php maintenance/update.php --quick
14. Restart the Containers
Apply all changes by restarting the Docker containers:
docker compose up -d
Advanced Configuration
Now that your basic MediaWiki installation is running, let's customize it with logos, permissions, email notifications, and private namespaces.
Part 1: Customizing Your Wiki's Appearance
15. Upload Your Logo Files
Before configuring logos, you need to upload your logo images to the wiki's images folder.
Step A: Prepare Your Logo Files
Create logo images in these sizes:
- Small logo (50x50 pixels): For favicon and small displays - save as
yourlogo-50.svgoryourlogo-50.png - Large logo (160x160 pixels): For the main wiki logo - save as
yourlogo-160.svgoryourlogo-160.png
Tip: SVG format is recommended because it scales cleanly at any size. PNG is also acceptable.
Step B: Copy Logo Files to the Server
First, you need to create the images directory on your host machine since we're using a Docker volume:
# Create a temporary container to access the images volume
docker run -d --name temp-mediawiki \
-v 230912_images:/var/www/html/images \
mediawiki sleep 3600
# Copy your logo files into the container
docker cp ~/Downloads/yourlogo-50.svg temp-mediawiki:/var/www/html/images/
docker cp ~/Downloads/yourlogo-160.svg temp-mediawiki:/var/www/html/images/
# Fix permissions
docker exec temp-mediawiki chown 33:33 /var/www/html/images/yourlogo-50.svg
docker exec temp-mediawiki chown 33:33 /var/www/html/images/yourlogo-160.svg
# Remove the temporary container
docker stop temp-mediawiki
docker rm temp-mediawiki
Note: Replace yourlogo-50.svg and yourlogo-160.svg with your actual filename. Adjust the path ~/Downloads/ if your files are saved elsewhere.
16. Configure Logo and Favicon in LocalSettings.php
Open your LocalSettings.php file:
sudo nano /opt/stacks/mediawiki/LocalSettings.php
Find the existing $wgLogos section (it looks like this):
$wgLogos = [
'1x' => "$wgResourceBasePath/resources/assets/change-your-logo.svg",
'icon' => "$wgResourceBasePath/resources/assets/change-your-logo.svg",
];
Replace it with:
$wgLogos = [
'1x' => "$wgResourceBasePath/images/yourlogo-160.svg",
'icon' => "$wgResourceBasePath/images/yourlogo-50.svg",
];
$wgFavicon = "$wgResourceBasePath/images/yourlogo-50.svg";
What this does:
'1x'sets your main wiki logo (shown in the corner)'icon'sets the smaller icon version$wgFaviconsets the browser tab icon
Save and exit.
Part 2: Customizing the Wiki Skin (Theme)
17. Configure the Modern Vector Skin
MediaWiki comes with several "skins" (visual themes). The Vector skin has a modern version called vector-2022.
Open LocalSettings.php again:
sudo nano /opt/stacks/mediawiki/LocalSettings.php
Find this line near the bottom:
$wgDefaultSkin = "monobook";
Replace it with this configuration block:
# Use the modern Vector 2022 skin by default
$wgDefaultSkin = "vector-2022";
# Make existing users see the new skin too
$wgVectorDefaultSkinVersionForExistingAccounts = "2";
# Make the skin work well on mobile devices
$wgVectorResponsive = true;
# Enable appearance customization options for users
$wgVectorFeatureFlags = [
'VectorAppearance' => [
'logged_in' => true,
'logged_out' => true,
],
];
What this does:
- Sets the modern Vector skin as default
- Makes it responsive for mobile/tablet viewing
- Allows users to customize appearance settings
Save and exit.
Part 3: Setting Up Email and SMTP
This allows your wiki to send password reset emails, notifications, and user-to-user messages.
18. Configure Email Settings
Important: This example uses Gmail. If using another email provider, you'll need their SMTP settings.
Step A: Generate a Gmail App Password
If using Gmail, you need an "App Password" (regular passwords won't work):
- Go to your Google Account: https://myaccount.google.com/
- Click Security in the left sidebar
- Scroll to "How you sign in to Google"
- Click 2-Step Verification (you must enable this first)
- Scroll down and click App passwords
- Select Mail and Other (Custom name)
- Type "MediaWiki" as the name
- Click Generate
- Copy the 16-character password (it looks like:
abcd efgh ijkl mnop)
Step B: Add Email Configuration to LocalSettings.php
Open LocalSettings.php:
sudo nano /opt/stacks/mediawiki/LocalSettings.php
Scroll to the bottom (after the extensions section) and add:
/*-------------------------------------------
EMAIL & SMTP CONFIGURATION
----------------------------------------- */
# Enable email features
$wgEnableEmail = true;
$wgEnableUserEmail = true;
$wgEmailAuthentication = true;
# Enable email notifications for talk pages and watchlist
$wgEnotifUserTalk = true;
$wgEnotifWatchlist = true;
# Set your wiki's email addresses
$wgEmergencyContact = "your-email@gmail.com";
$wgPasswordSender = "your-email@gmail.com";
# Gmail SMTP configuration
$wgSMTP = [
'host' => 'smtp.gmail.com',
'IDHost' => 'yourdomain.com', # Your domain (or 'gmail.com' for testing)
'port' => 587,
'auth' => true,
'username' => 'your-email@gmail.com', # Your Gmail address
'password' => 'your app password here', # Paste your 16-character App Password
'secure' => 'tls'
];
# Email settings
$wgUserEmailUseReplyTo = true;
$wgAllowHTMLEmail = true;
# Enable password reset via email
$wgPasswordResetRoutes = [
'username' => true,
'email' => true,
];
# Password reset links expire after 24 hours
$wgNewPasswordExpiry = 86400;
Replace these values:
your-email@gmail.com→ Your actual Gmail addressyour app password here→ The 16-character password from Step A (remove spaces)yourdomain.com→ Your wiki's domain name
Save and exit.
Part 4: Permission System (Who Can Do What)
19. Create a Clean Permission Structure
By default, MediaWiki allows anyone to edit. Let's create a more controlled system with different user levels.
Open LocalSettings.php:
sudo nano /opt/stacks/mediawiki/LocalSettings.php
Find the existing permissions section in your CUSTOM PERMISSIONS & EXTENSIONS block:
// 1. SECURITY: Prevent anonymous editing and account creation
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createaccount'] = false;
Replace it with this expanded permission system:
/*-------------------------------------------
CLEAN PERMISSION SYSTEM
----------------------------------------- */
# ANONYMOUS USERS (not logged in)
$wgGroupPermissions['*']['read'] = true; # Can view pages
$wgGroupPermissions['*']['edit'] = false; # Cannot edit
$wgGroupPermissions['*']['createaccount'] = false; # Cannot create accounts
# LOGGED-IN USERS (default group)
$wgGroupPermissions['user']['read'] = true; # Can view pages
$wgGroupPermissions['user']['edit'] = false; # Cannot edit (read-only)
# EDITOR GROUP (must be assigned by admin)
$wgGroupPermissions['editor']['read'] = true; # Can view pages
$wgGroupPermissions['editor']['edit'] = true; # Can edit pages
$wgGroupPermissions['editor']['upload'] = true; # Can upload files
$wgGroupPermissions['editor']['reupload'] = true; # Can replace existing files
# SYSOP GROUP (administrators)
$wgGroupPermissions['sysop']['read'] = true; # Can view pages
$wgGroupPermissions['sysop']['edit'] = true; # Can edit pages
$wgGroupPermissions['sysop']['protect'] = true; # Can protect pages
$wgGroupPermissions['sysop']['userrights'] = true; # Can assign user groups
# Enable protection levels
$wgRestrictionLevels[] = 'user';
What this permission structure means:
- Anonymous visitors: Can only read pages
- Logged-in users: Can only read pages (no editing)
- Editors: Can read, edit, and upload files (assigned by admins)
- Sysops (Admins): Full control over the wiki
How to assign the Editor role:
After restarting your wiki, log in as an admin and go to:
- Special:UserRights (or click Special Pages → User rights management)
- Enter a username
- Check the editor box
- Click Save user groups
Save and exit.
Part 5: Creating a Private Namespace
Private namespaces let you create pages that only certain user groups can see. This is useful for internal documentation, confidential information, or drafts.
20. Configure the Private Namespace
The Lockdown extension should already be installed from Step 10C. Now let's configure it.
Open LocalSettings.php:
sudo nano /opt/stacks/mediawiki/LocalSettings.php
Add this section after your extensions (near the bottom of the CUSTOM PERMISSIONS & EXTENSIONS block):
/*-------------------------------------------
PRIVATE NAMESPACE (RESTRICTED ACCESS)
----------------------------------------- */
# Load the Lockdown extension
wfLoadExtension( 'Lockdown' );
# Define namespace IDs (must be unique)
define("NS_PRIVATE", 3000);
define("NS_PRIVATE_TALK", 3001);
# Register the namespace names
$wgExtraNamespaces[NS_PRIVATE] = "Private";
$wgExtraNamespaces[NS_PRIVATE_TALK] = "Private_talk";
# Set permissions for the Private namespace
# Only logged-in users, editors, and admins can READ
$wgNamespacePermissionLockdown[NS_PRIVATE]['read'] = ['user', 'editor', 'sysop'];
# Only editors and admins can EDIT
$wgNamespacePermissionLockdown[NS_PRIVATE]['edit'] = ['editor', 'sysop'];
How to use the Private namespace:
To create a private page, use this format in the URL or search:
Private:YourPageName
Example: Private:Company_Policies
Anonymous users and non-logged-in visitors will get an access denied message.
Save and exit.
Part 6: Additional Recommended Extensions
These extensions add useful features for a professional wiki.
21. Enable Additional Extensions
Open LocalSettings.php:
sudo nano /opt/stacks/mediawiki/LocalSettings.php
Find your EXTERNAL EXTENSIONS section and expand it with these additional extensions:
// 3. EXTERNAL EXTENSIONS
wfLoadExtension( 'Mermaid' );
/*-------------------------------------------
ADDITIONAL RECOMMENDED EXTENSIONS
----------------------------------------- */
# Content organization
wfLoadExtension( 'CategoryTree' ); # Browse categories as tree structure
wfLoadExtension( 'ImageMap' ); # Clickable image regions
# User experience
wfLoadExtension( 'Echo' ); # Notification system
wfLoadExtension( 'Thanks' ); # Thank users for edits
wfLoadExtension( 'DiscussionTools' ); # Better talk page discussions
# Content features
wfLoadExtension( 'TemplateData' ); # Document templates
wfLoadExtension( 'TemplateStyles' ); # CSS styling for templates
wfLoadExtension( 'Poem' ); # Format poetry and verse
# File handling
wfLoadExtension( 'PdfHandler' ); # Display PDF thumbnails
wfLoadExtension( 'MultimediaViewer' ); # Better image viewing
# Moderation & security
wfLoadExtension( 'ConfirmEdit' ); # CAPTCHA for spam prevention
wfLoadExtension( 'SpamBlacklist' ); # Block spam URLs
wfLoadExtension( 'TitleBlacklist' ); # Block page title patterns
wfLoadExtension( 'CiteThisPage' ); # Citation tools
Note: Some of these extensions may already be included in your MediaWiki installation. If you get an error about a missing extension after restarting, simply comment out that line by adding # at the beginning or remove it entirely.
Save and exit.
Part 7: Enable File Uploads
22. Configure Upload Settings
Open LocalSettings.php:
sudo nano /opt/stacks/mediawiki/LocalSettings.php
Find the line with $wgEnableUploads and update the upload settings:
# Enable file uploads
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
$wgUseInstantCommons = false;
# Allow these file types to be uploaded
$wgFileExtensions = ['png','gif','jpg','jpeg','webp','svg','pdf','doc','docx','xls','xlsx'];
# Allow SVG files with embedded titles
$wgAllowTitleInSVG = true;
$wgSVGConverter = 'ImageMagick';
Note: You can add or remove file extensions based on your needs. Be cautious about allowing executable files or scripts.
Save and exit.
Part 8: Apply All Changes
23. Update the Database and Restart
After making all these configuration changes, update your database and restart the containers:
# Update database to recognize new extensions and namespaces
docker exec -it mediawiki php maintenance/update.php --quick
# Restart MediaWiki to apply all changes
cd /opt/stacks/mediawiki
docker compose restart
Wait about 30 seconds for the containers to fully restart.
Verification
Your MediaWiki installation should now be fully functional. Visit your wiki in a web browser to verify:
https://mediawiki.yourdomain.com
You should see your wiki homepage with all extensions activated.
Verification Checklist
24. Test Your Configuration
Visit your wiki and verify these features are working:
- Logo: Your custom logo appears in the top-left corner and as the favicon
- Skin: The modern Vector 2022 skin is active
- Permissions:
- Log out and confirm you can only read pages
- Log in as a regular user and confirm you cannot edit
- Log in as admin and assign the "editor" role to a test user via Special:UserRights
- Confirm the editor can now edit pages
- Email:
- Click "Forgot password?" on the login page
- Enter your username or email
- Check that you receive the reset email
- Private Namespace:
- Create a page like
Private:Test - Log out and confirm anonymous users cannot access it
- Log in as a regular user and confirm you can view it
- Check that only editors and admins can edit it
- File Uploads:
- Log in as an editor or admin
- Go to Special:Upload
- Try uploading an image file
- Verify it appears on the page
Troubleshooting
If you encounter issues:
Email not sending?
- Verify your Gmail App Password is correct (16 characters, no spaces)
- Check that 2-Step Verification is enabled on your Google account
- Look at container logs:
docker compose logs -f mediawiki
Logo not appearing?
- Verify files were copied correctly:
docker exec mediawiki ls -la /var/www/html/images/ - Hard refresh your browser:
Ctrl + Shift + R(Windows/Linux) orCmd + Shift + R(Mac) - Check the exact filenames in LocalSettings.php match the uploaded files
Private namespace not working?
- Ensure Lockdown extension is installed:
ls /opt/stacks/mediawiki/extensions/Lockdown - Run database update:
docker exec -it mediawiki php maintenance/update.php --quick - Restart containers:
docker compose restart
Extension errors?
- Check if extension exists:
ls /opt/stacks/mediawiki/extensions/ - Update database:
docker exec -it mediawiki php maintenance/update.php --quick - View error messages:
docker compose logs -f
General troubleshooting commands:
- Check container logs:
docker compose logs -f
- Restart containers:
docker compose restart
- Verify file permissions:
ls -la /opt/stacks/mediawiki/
- Check if MediaWiki container is running:
docker ps
Complete LocalSettings.php Example
For reference, here's what a complete LocalSettings.php file should look like with all configurations:
<?php
# This file was automatically generated by the MediaWiki installer.
# See includes/MainConfigSchema.php for all configurable settings
# and their default values.
# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
exit;
}
## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;
$wgSitename = "Your Wiki Name";
$wgMetaNamespace = "Your_Wiki_Name";
## The URL base path to the directory containing the wiki
$wgScriptPath = "";
## The protocol and server name to use in fully-qualified URLs
$wgServer = "https://mediawiki.yourdomain.com";
## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;
## The URL paths to the logo
$wgLogos = [
'1x' => "$wgResourceBasePath/images/yourlogo-160.svg",
'icon' => "$wgResourceBasePath/images/yourlogo-50.svg",
];
$wgFavicon = "$wgResourceBasePath/images/yourlogo-50.svg";
## UPO means: this is also a user preference option
$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO
$wgEmergencyContact = "your-email@gmail.com";
$wgPasswordSender = "your-email@gmail.com";
$wgEnotifUserTalk = true; # UPO
$wgEnotifWatchlist = true; # UPO
$wgEmailAuthentication = true;
## Database settings
$wgDBtype = "mysql";
$wgDBserver = "mediawiki-db";
$wgDBname = "my_wiki";
$wgDBuser = "wikiuser";
$wgDBpassword = "your_secure_password";
# MySQL specific settings
$wgDBprefix = "";
$wgDBssl = false;
# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
# Shared database table
$wgSharedTables[] = "actor";
## Shared memory settings
$wgMainCacheType = CACHE_ACCEL;
$wgMemCachedServers = [];
## To enable image uploads
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
# Allow these file types
$wgFileExtensions = ['png','gif','jpg','jpeg','webp','svg','pdf','doc','docx','xls','xlsx'];
# SVG settings
$wgAllowTitleInSVG = true;
$wgSVGConverter = 'ImageMagick';
# InstantCommons allows wiki to use images from https://commons.wikimedia.org
$wgUseInstantCommons = false;
# Periodically send a pingback to https://www.mediawiki.org/
$wgPingback = true;
# Site language code
$wgLanguageCode = "en";
# Time zone
$wgLocaltimezone = "UTC";
## Set $wgCacheDirectory to a writable directory on the web server
#$wgCacheDirectory = "$IP/cache";
$wgSecretKey = "generated_during_installation";
# Changing this will log out all existing sessions.
$wgAuthenticationTokenVersion = "1";
# Site upgrade key
$wgUpgradeKey = "generated_during_installation";
## For attaching licensing metadata to pages
$wgRightsPage = "";
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";
# Path to the GNU diff3 utility
$wgDiff3 = "/usr/bin/diff3";
## Default skin
$wgDefaultSkin = "vector-2022";
# Make existing users see the new skin too
$wgVectorDefaultSkinVersionForExistingAccounts = "2";
# Make the skin work well on mobile devices
$wgVectorResponsive = true;
# Enable appearance customization options for users
$wgVectorFeatureFlags = [
'VectorAppearance' => [
'logged_in' => true,
'logged_out' => true,
],
];
# Enabled skins
wfLoadSkin( 'MinervaNeue' );
wfLoadSkin( 'MonoBook' );
wfLoadSkin( 'Timeless' );
wfLoadSkin( 'Vector' );
# End of automatically generated settings.
# Add more configuration options below.
/*-------------------------------------------
CLEAN PERMISSION SYSTEM
----------------------------------------- */
# ANONYMOUS USERS (not logged in)
$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createaccount'] = false;
# LOGGED-IN USERS (default group)
$wgGroupPermissions['user']['read'] = true;
$wgGroupPermissions['user']['edit'] = false;
# EDITOR GROUP (must be assigned by admin)
$wgGroupPermissions['editor']['read'] = true;
$wgGroupPermissions['editor']['edit'] = true;
$wgGroupPermissions['editor']['upload'] = true;
$wgGroupPermissions['editor']['reupload'] = true;
# SYSOP GROUP (administrators)
$wgGroupPermissions['sysop']['read'] = true;
$wgGroupPermissions['sysop']['edit'] = true;
$wgGroupPermissions['sysop']['protect'] = true;
$wgGroupPermissions['sysop']['userrights'] = true;
# Enable protection levels
$wgRestrictionLevels[] = 'user';
/*-------------------------------------------
BUNDLED EXTENSIONS
----------------------------------------- */
wfLoadExtension( 'WikiEditor' );
wfLoadExtension( 'VisualEditor' );
wfLoadExtension( 'CodeEditor' );
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
wfLoadExtension( 'Cite' );
wfLoadExtension( 'InputBox' );
wfLoadExtension( 'Scribunto' );
wfLoadExtension( 'AbuseFilter' );
wfLoadExtension( 'Gadgets' );
wfLoadExtension( 'ParserFunctions' );
/*-------------------------------------------
EXTERNAL EXTENSIONS
----------------------------------------- */
wfLoadExtension( 'Mermaid' );
/*-------------------------------------------
ADDITIONAL RECOMMENDED EXTENSIONS
----------------------------------------- */
# Content organization
wfLoadExtension( 'CategoryTree' );
wfLoadExtension( 'ImageMap' );
# User experience
wfLoadExtension( 'Echo' );
wfLoadExtension( 'Thanks' );
wfLoadExtension( 'DiscussionTools' );
# Content features
wfLoadExtension( 'TemplateData' );
wfLoadExtension( 'TemplateStyles' );
wfLoadExtension( 'Poem' );
# File handling
wfLoadExtension( 'PdfHandler' );
wfLoadExtension( 'MultimediaViewer' );
# Moderation & security
wfLoadExtension( 'ConfirmEdit' );
wfLoadExtension( 'SpamBlacklist' );
wfLoadExtension( 'TitleBlacklist' );
wfLoadExtension( 'CiteThisPage' );
/*-------------------------------------------
PRIVATE NAMESPACE (RESTRICTED ACCESS)
----------------------------------------- */
# Load the Lockdown extension
wfLoadExtension( 'Lockdown' );
# Define namespace IDs
define("NS_PRIVATE", 3000);
define("NS_PRIVATE_TALK", 3001);
# Register the namespace names
$wgExtraNamespaces[NS_PRIVATE] = "Private";
$wgExtraNamespaces[NS_PRIVATE_TALK] = "Private_talk";
# Set permissions for the Private namespace
$wgNamespacePermissionLockdown[NS_PRIVATE]['read'] = ['user', 'editor', 'sysop'];
$wgNamespacePermissionLockdown[NS_PRIVATE]['edit'] = ['editor', 'sysop'];
/*-------------------------------------------
EMAIL & SMTP CONFIGURATION
----------------------------------------- */
$wgEnableEmail = true;
$wgEnableUserEmail = true;
$wgEmailAuthentication = true;
$wgEnotifUserTalk = true;
$wgEnotifWatchlist = true;
$wgEmergencyContact = "your-email@gmail.com";
$wgPasswordSender = "your-email@gmail.com";
$wgSMTP = [
'host' => 'smtp.gmail.com',
'IDHost' => 'yourdomain.com',
'port' => 587,
'auth' => true,
'username' => 'your-email@gmail.com',
'password' => 'your app password here',
'secure' => 'tls'
];
$wgUserEmailUseReplyTo = true;
$wgAllowHTMLEmail = true;
$wgPasswordResetRoutes = [
'username' => true,
'email' => true,
];
$wgNewPasswordExpiry = 86400;
/*-------------------------------------------
EXTENSION CONFIGURATION
----------------------------------------- */
# VisualEditor
$wgDefaultUserOptions['visualeditor-enable'] = 1;
$wgVisualEditorParsoidForwardCookies = true;
# Scribunto (Lua)
$wgScribuntoDefaultEngine = 'luastandalone';
/*-------------------------------------------
LOGIN SECURITY
----------------------------------------- */
$wgRateLimits['user']['login'] = [ 5, 60 ];
$wgRateLimits['ip']['login'] = [ 20, 300 ];
Next Steps
Your MediaWiki installation is now fully configured! You can:
- Create user accounts and assign the "editor" role via Special:UserRights
- Start creating content in the main namespace
- Create private documentation in the
Private:namespace - Customize the main page by editing MediaWiki:Mainpage
- Explore Special:SpecialPages to discover all available features
- Set up automatic backups of your wiki database and files
- Configure SSL/HTTPS if not already done
- Install additional extensions from https://www.mediawiki.org/wiki/Category:Extensions
For additional help, visit the official MediaWiki documentation at https://www.mediawiki.org/
Maintenance Tasks
Regular Backups
Create a backup script for your wiki:
#!/bin/bash
# Save as /opt/scripts/backup-mediawiki.sh
BACKUP_DIR="/opt/backups/mediawiki"
DATE=$(date +%Y%m%d_%H%M%S)
mkdir -p $BACKUP_DIR
# Backup database
docker exec mediawiki-db mysqldump -u root -pyour_root_password my_wiki > $BACKUP_DIR/db_$DATE.sql
# Backup LocalSettings.php
cp /opt/stacks/mediawiki/LocalSettings.php $BACKUP_DIR/LocalSettings_$DATE.php
# Backup images (use docker volume backup)
docker run --rm -v 230912_images:/data -v $BACKUP_DIR:/backup alpine tar czf /backup/images_$DATE.tar.gz -C /data .
echo "Backup completed: $DATE"
Updating MediaWiki
When a new version is released:
# Pull the latest MediaWiki image
docker pull mediawiki:latest
# Restart with the new image
cd /opt/stacks/mediawiki
docker compose down
docker compose up -d
# Update the database schema
docker exec -it mediawiki php maintenance/update.php
# Clear the cache
docker exec -it mediawiki php maintenance/rebuildLocalisationCache.php
Summary
You've successfully set up a complete MediaWiki installation with:
✓ Docker containerization for easy management
✓ Custom logos and modern theme
✓ Email notifications via SMTP
✓ Multi-level permission system
✓ Private namespace for confidential content
✓ Essential and recommended extensions
✓ File upload capabilities
✓ Security hardening
Your wiki is now ready for production use!