MediaWiki is an open-source platform for creating and maintaining collaborative websites, commonly used to power wikis like Wikipedia. In this tutorial, you’ll learn how to install MediaWiki on Debian 12. We’ll guide you step-by-step through the process, from preparing the server environment to accessing your MediaWiki instance.

Key Features:

  • Collaborative Editing: Multiple users can contribute to the content, allowing for easy collaboration and modification of articles.
  • Version Control: Every edit is tracked, with the ability to revert to previous versions, making it easy to manage changes.
  • Extensions: MediaWiki is highly extensible through a wide variety of plugins that add functionality like enhanced permissions, discussion tools, or integration with other software.
  • Categorization and Search: It supports categorizing content and provides a robust search engine, which helps users locate articles efficiently.
  • Multilingual Support: MediaWiki supports multiple languages, allowing users to create wikis in various languages.
  • Rich Media: The platform allows users to upload and embed images, videos, and other media, enhancing the content with multimedia elements.
  • Templates and Skins: MediaWiki allows customization of page layouts and designs through templates and skins, helping standardize content and control the wiki’s appearance.

Common Uses:

  • Wikipedia and Other Wikis: MediaWiki is the software behind Wikipedia, but it’s also used by other Wikimedia projects like Wiktionary and Wikibooks.
  • Corporate Knowledge Bases: Many companies use MediaWiki to build internal knowledge bases, technical guides, and process documentation.
  • Education: Schools and universities use MediaWiki for course management, content sharing, and collaborative learning environments.
  • Technical Documentation: Developers and companies use MediaWiki to maintain product documentation and support resources.
  • Fan and Community Wikis: MediaWiki is commonly used by fan communities to build collaborative databases on topics like games, TV shows, or books.

Advantages:

  • Free and Open-source: MediaWiki is free to use and modify, allowing for extensive customization.
  • Scalable: It can support small or large wikis, making it ideal for both personal projects and large platforms.
  • Secure: Regular updates and security patches ensure that MediaWiki remains a secure platform.
  • Encourages Collaboration: Its core design allows multiple users to contribute, making it perfect for team-based knowledge projects.

MediaWiki is widely used in many environments, from educational settings and corporate environments to large-scale public wikis like Wikipedia.

Step 1: Create an Instance

  • Access the Dashboard: Log in to your Shape.Host account and navigate to your Dashboard.
  • Click Create: Click on the “Create” button located in the top-right corner.
  • Select Instances: From the dropdown menu, choose “Instances” to begin creating a new cloud server.
Shape.host Resources dashboard with Create > Instance highlighted.
  • Select Location: Choose a data center location for your instance closest to your target audience for optimal performance.
Shape.host instance form with the data center location selector highlighted.
  • Choose a Plan: Scroll through the available pricing plans. Select a plan based on your project requirements, such as Standard, CPU-Optimized, or Memory-Optimized.
  • Choose an Image: Select Debian 12 as the operating system for your instance.
Shape.host instance form with the operating system image selector highlighted.
  • Authentication and Finalize: Choose your authentication method, either via SSH keys or password. Once done, click Create Instance to launch your server.
Shape.host instance form with the Create Instance button highlighted.
  • Obtain IP Address
Shape.host Resources dashboard with the server IP address highlighted.

Step 2: Access Your MediaWiki Instance

To connect to your instance on Shape.Host, follow these steps:

  1. Get the Instance IP: After creating your instance, find the public IP address in the Shape.Host dashboard under Resources.
  2. Open SSH Client: Use an SSH client like Terminal (Linux/macOS) or PuTTY (Windows).
  3. SSH into the Instance: Run the following command in your terminal:
   ssh root@<your-instance-ip>

Replace <your-instance-ip> with your actual instance IP address.

  1. Enter the Password: If prompted, enter your instance’s root password or use your SSH key if configured.

You are now connected to your instance!

Step 3: Update System Packages

Start by updating the system’s package index to ensure all software is up-to-date:

apt update
Terminal showing APT package management commands and output.

Step 4: Install Apache, MariaDB, and PHP

MediaWiki requires a web server, a database, and PHP to function properly. Install Apache, MariaDB, and the required PHP modules:

apt install apache2 mariadb-server imagemagick libapache2-mod-php php php-common php-intl php-xml php-curl php-gd php-mbstring php-mysql php-apcu
Terminal showing APT package management commands and output.

Step 5: Verify Apache, MariaDB, and PHP

Ensure that Apache and MariaDB are enabled and running:

systemctl is-enabled apache2
systemctl status apache2

systemctl is-enabled mariadb
systemctl status mariadb
Terminal showing systemd service management commands or output.
Terminal showing systemd service management commands or output.

Check the installed PHP version:

php -v

Verify the PHP modules installed:

php -m
Terminal showing php commands or output during Verify Apache, MariaDB, and PHP.

Step 6: Configure PHP

Edit the PHP configuration file to optimize it for MediaWiki:

nano /etc/php/8.2/apache2/php.ini

Make the following changes to the file:

  • Set your timezone (e.g., date.timezone = Europe/Amsterdam)
  • Adjust upload_max_filesize to 80M
  • Set memory_limit to 512M
  • Set max_execution_time to 360

To save and exit from Nano, follow these steps:

  • Save the changes:
  • Press Ctrl + O (the letter “O”) to save the file. Nano will show a prompt asking for confirmation with the filename.
  • Press Enter to confirm and save the file with the current name.
  • Exit Nano:
  • Press Ctrl + X to exit Nano.

This will save your changes and close the editor.

Save the changes and restart Apache:

systemctl restart apache2
Terminal showing systemd service management commands or output.

Step 7: Secure MariaDB Installation

Run the MariaDB secure installation script to set up your database:

mariadb-secure-installation
Terminal showing MariaDB/MySQL database security configuration prompts.
Terminal showing mariadb commands or output during Secure MariaDB Installation.

Follow the prompts to secure your MariaDB installation.

Step 8: Create a Database for MediaWiki

Log in to the MariaDB server to create a database and user for MediaWiki:

mariadb -u root -p

Run the following SQL commands:

CREATE DATABASE mediawikidb;
CREATE USER 'mediawiki'@'localhost' IDENTIFIED BY 'mediawikipassdb';
GRANT ALL PRIVILEGES ON mediawikidb.* TO 'mediawiki'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Verify the user’s privileges:

SHOW GRANTS FOR 'mediawiki'@'localhost';
Terminal showing SQL database and user configuration commands.

Type quit to exit from the MariaDB when finished.

Step 9: Download and Extract MediaWiki

Change to the web directory and download MediaWiki:

cd /var/www/
wget https://releases.wikimedia.org/mediawiki/1.41/mediawiki-1.41.0.tar.gz
tar -xvzf mediawiki-*.tar.gz
mv mediawiki-*/ mediawiki/
Terminal showing file and directory setup commands.
Terminal showing file download commands and transfer output.
Terminal showing tar commands or output during Download and Extract MediaWiki.
Terminal showing file and directory setup commands.

Change ownership and set permissions:

chown -R www-data:www-data /var/www/mediawiki
chmod 755 /var/www/mediawiki
Terminal showing file ownership or permission commands.

Step 10: Configure Apache for MediaWiki

Enable the Apache rewrite module:

a2enmod rewrite
Terminal showing systemd service management commands or output.

Create a new virtual host configuration file for MediaWiki:

nano /etc/apache2/sites-available/mediawiki.conf

Insert the following configuration, adjusting the ServerName and log file paths as needed:

<VirtualHost *:80>
 ServerName debian.shape.host
 ServerAdmin contact@shape.host
 DocumentRoot /var/www/mediawiki

 ErrorLog /var/log/apache2/debian.shape.host_error.log
 CustomLog /var/log/apache2/debian.shape.host_access.log combined

 <Directory /var/www/mediawiki/>
   Options FollowSymlinks
   AllowOverride All
   Require all granted
 </Directory>
</VirtualHost>
Terminal showing web server configuration text.

To save and exit from Nano, follow these steps:

  • Save the changes:
  • Press Ctrl + O (the letter “O”) to save the file. Nano will show a prompt asking for confirmation with the filename.
  • Press Enter to confirm and save the file with the current name.
  • Exit Nano:
  • Press Ctrl + X to exit Nano.

This will save your changes and close the editor.

Enable the new site and check Apache’s configuration:

a2ensite mediawiki.conf
apachectl configtest
Terminal showing an Apache configuration test.

Restart Apache to apply the changes:

systemctl restart apache2
Terminal showing systemd service management commands or output.

Step 11: Enable HTTPS with Let’s Encrypt

Install Certbot and enable HTTPS for your domain:

apt install certbot python3-certbot-apache
certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email contact@shape.host -d debian.shape.host
Terminal showing APT package management commands and output.
Terminal showing Certbot certificate commands and messages.

Step 12: Complete MediaWiki Setup

Open your web browser and navigate to your domain (e.g., http://debian.shape.host/). You should see the MediaWiki welcome page. Click the set up the wiki link to proceed with the configuration.

MediaWiki message that LocalSettings.php is missing, with a link to complete setup.

Select the default language for your MediaWiki and click Continue.

MediaWiki installer language selection.

For the environment checks, make sure your system is met with the MediaWiki requirements. Then, click Continue again.

MediaWiki installer welcome, environment checks and license information.

Select the database as MariaDB and input your name, user, and password. Then, click Continue to proceed.

MediaWiki installer database connection settings.

Next, input your admin username, email, and password for MediaWiki, then click Continue.

MediaWiki installer wiki-name and administrator account settings.

For additional settings, select the default theme that you want to use, then click Continue to proceed with the installation.

MediaWiki installer with logo and caching configuration options.

Click Continue to confirm the MediaWiki installation.

MediaWiki installation confirmation before creating database tables.
MediaWiki database installation progress checklist.

Once the installation is complete, the file LocalSettings.php will automatically downloaded to your local computer and you will see an instruction to upload the file to your MediaWiki installation directory.

MediaWiki setup completion page with the LocalSettings.php download.

Back to your terminal and run the command below to create a new file LocalSettings.php.

nano /var/www/mediawiki/LocalSettings.php

Open the file LocalSettings.php you downloaded, and copy and paste the PHP code into your server. Then, save the file and exit.

Return to your web browser and click the link to enter the wiki. You will see the default home page of MediaWiki that you have installed.

MediaWiki main page after installation, with getting-started links.

This tutorial was made possible using Shape.Host services, specifically their Cloud VPS offering. Shape.Host provides reliable and scalable cloud hosting solutions that are ideal for hosting applications like MediaWiki. Check out their Cloud VPS plans to get started with your own instance today.