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.
- Select Location: Choose a data center location for your instance closest to your target audience for optimal performance.
- 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.
- Authentication and Finalize: Choose your authentication method, either via SSH keys or password. Once done, click Create Instance to launch your server.
- Obtain IP Address
Step 2: Access Your MediaWiki Instance
To connect to your instance on Shape.Host, follow these steps:
- Get the Instance IP: After creating your instance, find the public IP address in the Shape.Host dashboard under Resources.
- Open SSH Client: Use an SSH client like Terminal (Linux/macOS) or PuTTY (Windows).
- 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.
- 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
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
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
Check the installed PHP version:
php -v
Verify the PHP modules installed:
php -m
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
to80M
- Set
memory_limit
to512M
- Set
max_execution_time
to360
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
Step 7: Secure MariaDB Installation
Run the MariaDB secure installation script to set up your database:
mariadb-secure-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';
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/
Change ownership and set permissions:
chown -R www-data:www-data /var/www/mediawiki
chmod 755 /var/www/mediawiki
Step 10: Configure Apache for MediaWiki
Enable the Apache rewrite module:
a2enmod rewrite
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>
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
Restart Apache to apply the changes:
systemctl restart apache2
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
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.
Select the default language for your MediaWiki and click Continue.
For the environment checks, make sure your system is met with the MediaWiki requirements. Then, click Continue again.
Select the database as MariaDB and input your name, user, and password. Then, click Continue to proceed.
Next, input your admin username, email, and password for MediaWiki, then click Continue.
For additional settings, select the default theme that you want to use, then click Continue to proceed with the installation.
Click Continue to confirm the MediaWiki installation.
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.
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.
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.