DebianDebian Based

How To Install MediaWiki on Debian 13

Install MediaWiki on Debian 13

MediaWiki stands as the powerful engine behind Wikipedia and thousands of knowledge bases worldwide. This collaborative platform transforms how organizations manage documentation, create internal wikis, and build comprehensive knowledge repositories. Debian 13, with its renowned stability and security features, provides an ideal foundation for hosting your MediaWiki installation.

Whether you’re building a corporate knowledge base, community documentation site, or personal wiki, this guide walks you through every step of installing MediaWiki on Debian 13. You’ll learn how to set up the complete server environment, configure databases, and deploy a fully functional wiki ready for content creation. The process requires basic Linux command-line knowledge, SSH access to your server, and sudo privileges.

Prerequisites and Requirements

System Requirements

MediaWiki runs efficiently on modest hardware. The official minimum specifications call for 256MB RAM and 85MB disk storage. However, production environments benefit significantly from at least 2GB RAM and 10GB storage space, especially as your wiki grows and attracts more users.

For wikis serving small teams or personal projects, a basic VPS or cloud instance works perfectly. Larger organizations managing extensive documentation should consider dedicated servers with multiple CPU cores. Page rendering speed and database query performance scale directly with available system resources.

Software Prerequisites

Your Debian 13 system should be freshly installed with either minimal or standard configuration. You’ll need root access or a user account with sudo privileges to install packages and modify system files. A stable internet connection ensures smooth package downloads from Debian repositories.

While prior experience with web servers and databases proves helpful, this tutorial provides clear explanations suitable for Linux users at various skill levels. Familiarity with text editors like nano or vim streamlines the configuration process.

Step 1: Update Debian 13 System

Before installing any new software, updating your Debian system establishes a secure foundation. This critical step ensures compatibility between packages and patches known security vulnerabilities.

Run these commands to refresh your package lists and upgrade installed software:

sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y

The update command synchronizes package indexes with Debian repositories. The upgrade command installs newer versions of existing packages. Finally, autoremove cleans up unnecessary dependencies, freeing disk space.

Step 2: Install LAMP Stack Components

MediaWiki requires a LAMP stack—Linux, Apache, MySQL (MariaDB), and PHP. Each component plays a vital role in serving your wiki to users.

Install Apache Web Server

Apache handles HTTP requests and serves web pages to visitors. Install and configure it with these commands:

sudo apt install apache2 -y
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl status apache2

The enable command ensures Apache starts automatically after system reboots. Verify the installation by opening your server’s IP address in a web browser. You should see the default Apache welcome page.

Install MariaDB Database Server

MariaDB stores your wiki content, user accounts, and configuration data. Install the database server and secure it:

sudo apt install mariadb-server -y
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation

The secure installation script guides you through essential security measures. Set a strong root password when prompted. Remove anonymous user accounts. Disallow remote root login to prevent unauthorized access. Delete the test database that serves no production purpose. Reload privilege tables to apply changes immediately.

Install PHP and Required Extensions

PHP processes MediaWiki’s code and generates dynamic content. MediaWiki depends on several PHP extensions for full functionality:

sudo apt install php libapache2-mod-php php-mysql php-intl php-mbstring php-apcu php-xml php-curl php-gd -y

Each extension serves specific purposes. The php-mysql extension enables database connectivity. The php-intl package handles internationalization for multilingual wikis. The php-mbstring extension processes multibyte character encoding. The php-apcu module provides performance-enhancing memory caching. The php-xml library parses XML data structures. The php-curl extension manages HTTP requests. The php-gd toolkit processes images for thumbnails and graphics.

Restart Apache to activate PHP:

sudo systemctl restart apache2

Step 3: Create MediaWiki Database

Your wiki needs a dedicated database with appropriate access credentials. Log into MariaDB as root:

sudo mysql -u root -p

Enter your root password when prompted. Execute these SQL commands at the MariaDB prompt:

CREATE DATABASE mediawiki_db;
CREATE USER 'mediawiki_user'@'localhost' IDENTIFIED BY 'your_strong_password';
GRANT ALL PRIVILEGES ON mediawiki_db.* TO 'mediawiki_user'@'localhost';
FLUSH PRIVILEGES;
exit;

Replace your_strong_password with a complex password combining uppercase letters, lowercase letters, numbers, and special characters. Choose a password at least 16 characters long. Document these credentials securely—you’ll need them during MediaWiki configuration.

Database security hinges on strong passwords and limited privileges. Never use simple passwords like “password123” or “admin.” Consider using a password manager to generate and store secure credentials.

Step 4: Download MediaWiki

Always download MediaWiki from official sources to ensure file integrity and security. Navigate to your temporary directory:

cd /tmp

Download the latest stable MediaWiki release. As of this writing, version 1.43 represents the current stable branch:

wget https://releases.wikimedia.org/mediawiki/1.43/mediawiki-1.43.0.tar.gz

Check the official MediaWiki download page for the most recent version number. The project maintains multiple release branches with different support timelines. Long-term support (LTS) versions receive extended security updates, making them ideal for production environments.

Step 5: Extract and Move MediaWiki Files

Extract the downloaded archive:

tar -xzf mediawiki-*.tar.gz

Move the extracted files to your web server’s document root:

sudo mv mediawiki-* /var/www/html/mediawiki

The /var/www/html directory serves as Apache’s default document root on Debian systems. Some administrators prefer alternative locations like /var/www/mediawiki or /opt/mediawiki. Choose a location that aligns with your server management practices.

Set proper ownership and permissions:

sudo chown -R www-data:www-data /var/www/html/mediawiki
sudo chmod -R 755 /var/www/html/mediawiki

The www-data user represents Apache’s process owner on Debian. Correct ownership allows Apache to read configuration files and write uploaded content. The 755 permission mode grants read and execute access to all users while restricting write access to the owner.

Step 6: Configure Apache Virtual Host

Virtual hosts allow Apache to serve multiple websites from a single server. Create a dedicated configuration file for MediaWiki:

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

Add this configuration, replacing placeholders with your actual domain:

<VirtualHost *:80>
    ServerName your-domain.com
    ServerAdmin admin@your-domain.com
    DocumentRoot /var/www/html/mediawiki
    
    <Directory /var/www/html/mediawiki>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    
    ErrorLog ${APACHE_LOG_DIR}/mediawiki_error.log
    CustomLog ${APACHE_LOG_DIR}/mediawiki_access.log combined
</VirtualHost>

The ServerName directive specifies your wiki’s domain name. The DocumentRoot points to your MediaWiki installation. The Directory block configures access permissions and Apache behavior. Error and access logs provide valuable troubleshooting information.

Enable the new virtual host and required modules:

sudo a2ensite mediawiki.conf
sudo a2enmod rewrite
sudo apache2ctl configtest
sudo systemctl restart apache2

The configtest command validates your Apache configuration syntax before restarting the service. Always run this test to catch configuration errors before they cause service disruptions.

Step 7: Run MediaWiki Web Installer

MediaWiki includes a user-friendly web-based installer that simplifies initial configuration. Open your web browser and navigate to your server’s address: http://your-server-ip/mediawiki or http://your-domain.com.

You’ll see a message stating “LocalSettings.php not found.” This expected behavior indicates MediaWiki hasn’t been configured yet. Click the “Please set up the wiki first” link to launch the installer.

Install MediaWiki on Debian 13

Language Selection

Choose your preferred language for the installation interface and wiki content. MediaWiki supports hundreds of languages with robust multilingual capabilities. Click Continue.

Environment Check

The installer automatically verifies your system meets MediaWiki’s requirements. A green success message confirms all necessary components are present. Review any warnings carefully. Missing PHP extensions or version mismatches require attention before proceeding. Click Continue when ready.

Database Configuration

Select MariaDB as your database type. Enter the connection details you created earlier:

  • Database host: localhost
  • Database name: mediawiki_db
  • Database username: mediawiki_user
  • Database password: [your password from Step 3]

Leave the database table prefix blank for standard installations. Use a custom prefix like “mw_” if you’re sharing the database with other applications. Select InnoDB as the storage engine—it provides better reliability and transaction support than MyISAM. Choose Binary for the database character set. Click Continue.

Wiki Configuration

Provide your wiki’s basic information:

  • Wiki name: Choose a descriptive name visible to users
  • Administrator username: Your admin account name
  • Administrator password: Create a strong, unique password
  • Administrator email: A valid email address for notifications

The administrator account grants full control over your wiki, including user management, extension configuration, and content moderation. Protect these credentials carefully.

Additional Settings

Configure user permissions according to your wiki’s purpose. The default “Open wiki” profile allows anyone to read and edit. “Account creation required” restricts editing to registered users. “Private wiki” limits all access to authorized accounts.

Select an appropriate copyright license for your content. Options include Creative Commons licenses, GNU Free Documentation License, or traditional copyright. This choice affects how others can use and redistribute your wiki content.

Enable useful extensions like ParserFunctions for advanced templates and Cite for reference formatting. Choose a visual skin—Vector represents MediaWiki’s modern default interface. Click Continue.

Installation Completion

Review your configuration summary. MediaWiki displays all your choices before making permanent changes. Click Continue to begin the installation process.

The installer creates database tables, configures default settings, and establishes your administrator account. This process typically completes within 30-60 seconds.

Step 8: Download and Configure LocalSettings.php

Upon successful installation, MediaWiki generates LocalSettings.php containing your wiki’s configuration. Your browser automatically downloads this file. If automatic download fails, the installer displays the complete file contents for manual copying.

Transfer LocalSettings.php to your server. Users with command-line access can use SCP:

scp LocalSettings.php user@server-ip:/tmp/

Alternatively, SFTP clients like FileZilla or WinSCP provide graphical file transfer interfaces. Some users prefer directly creating the file on the server using nano or vim.

Move the file to your MediaWiki directory:

sudo mv /tmp/LocalSettings.php /var/www/html/mediawiki/
sudo chown www-data:www-data /var/www/html/mediawiki/LocalSettings.php
sudo chmod 644 /var/www/html/mediawiki/LocalSettings.php

LocalSettings.php contains sensitive information including database passwords. The 644 permission mode allows Apache to read the file while preventing unauthorized modifications.

Step 9: Verify MediaWiki Installation

Access your wiki at http://your-domain.com or http://your-server-ip/mediawiki. Your MediaWiki main page should display correctly with your chosen skin and configuration.

Test core functionality by logging in with your administrator credentials. Create a test page to verify editing works properly. Try saving changes and viewing revision history. Use the search feature to confirm indexing functions correctly.

If something doesn’t work as expected, check Apache error logs for clues:

sudo tail -f /var/log/apache2/mediawiki_error.log

Common issues include incorrect file permissions, missing PHP extensions, or database connection problems.

Post-Installation Security Hardening

Securing your MediaWiki installation protects against unauthorized access and malicious attacks.

Set Up SSL/TLS Certificate

Encrypt traffic between users and your server with HTTPS. Install Certbot for free Let’s Encrypt certificates:

sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache -d your-domain.com

Certbot automatically configures Apache for HTTPS and sets up automatic certificate renewal. Update LocalSettings.php to force HTTPS connections:

$wgServer = "https://your-domain.com";

Secure LocalSettings.php

Restrict direct web access to your configuration file. Add this directive to your Apache virtual host configuration inside the Directory block:

<Files "LocalSettings.php">
    Require all denied
</Files>

Restart Apache to apply changes.

Configure File Upload Security

If you enable file uploads, restrict allowed file types. Add these settings to LocalSettings.php:

$wgEnableUploads = true;
$wgFileExtensions = array('png', 'gif', 'jpg', 'jpeg', 'pdf', 'svg');

Set secure permissions on the upload directory:

sudo chmod 755 /var/www/html/mediawiki/images

Essential MediaWiki Configuration Tips

Customize your wiki by editing LocalSettings.php. Add your logo:

$wgLogo = "/path/to/your/logo.png";

Configure your timezone:

$wgLocaltimezone = "Asia/Jakarta";

Enable email notifications by configuring SMTP settings:

$wgSMTP = [
    'host' => 'smtp.example.com',
    'IDHost' => 'example.com',
    'port' => 587,
    'auth' => true,
    'username' => 'your-email@example.com',
    'password' => 'your-password'
];

Install additional extensions to enhance functionality. VisualEditor provides a WYSIWYG editing experience. Scribunto enables Lua scripting for advanced templates. Cargo creates queryable databases within your wiki.

Troubleshooting Common Issues

Cannot connect to database: Verify your database credentials in LocalSettings.php match those created during setup. Check if MariaDB is running with sudo systemctl status mariadb.

Internal error after installation: Enable error display by adding $wgShowExceptionDetails = true; to LocalSettings.php temporarily. Review Apache error logs for specific error messages.

Permission denied errors: Ensure www-data owns MediaWiki files and directories have appropriate permissions. Run sudo chown -R www-data:www-data /var/www/html/mediawiki.

White screen or blank page: PHP errors often cause blank displays. Check PHP error logs in /var/log/apache2/. Verify all required PHP extensions are installed and enabled.

Unable to upload images: Confirm the images directory exists with correct permissions. Verify $wgEnableUploads is set to true in LocalSettings.php. Check PHP’s upload_max_filesize and post_max_size values.

Congratulations! You have successfully installed MediaWiki. Thanks for using this tutorial to install the latest version of MediaWiki on Debian 13 “Trixie” system. For additional help or useful information, we recommend you check the official MediaWiki website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button