How to install MediaWiki on Debian

In this tutorial, we will guide you through the process of installing MediaWiki on Debian. MediaWiki is a free and open-source software suite developed to power Wikipedia and other Wikis. MediaWiki is written in PHP and uses a database to store content.

Prerequisites

Before we start with the installation process, we need to make sure that our server meets the following requirements:

Step 1 – Update system packages

Before we begin, we must ensure that all of our Debian system packages are up to date. To update, log in as root and then execute the following command:

apt-get update && apt-get upgrade

Enter your root password when prompted, then wait for the process to complete.

Step 2 – Install Apache web server

MediaWiki requires a web server to function, and we will be using Apache in this tutorial. Execute the following command to install Apache:

apt-get install apache2

Once the installation is complete, start the Apache service:

systemctl start apache2

Step 3 – Install MariaDB server

MediaWiki requires a database server for storing content, and MariaDB is a popular choice due to its speed and scalability. Execute the following command to install MariaDB:

apt-get install mariadb-server

Once installed, start the MariaDB service:

systemctl start mariadb

To secure the MariaDB installation, execute the following command:

mysql_secure_installation

Enter your root password when prompted and answer the questions to secure your installation.

Step 4 – Install PHP

MediaWiki is written in PHP, and thus we need to install PHP and its modules to run it. Execute the following command to install PHP and its modules:

apt-get install php php-fpm php-mysql php-xml php-mbstring php-gd

Step 5 – Install Git

MediaWiki requires Git for cloning its repository. Execute the following command to install Git:

apt-get install git

Step 6 – Clone MediaWiki repository

Now that we have all the prerequisite packages installed, we can proceed with cloning the MediaWiki repository. Navigate to your web server’s document root directory and execute the following command to clone the repository:

cd /var/www/html
git clone https://gerrit.wikimedia.org/r/mediawiki/core.git .

Make sure to include the dot at the end of the command to clone the repository into the current directory.

Step 7 – Configure MediaWiki

Before we can use MediaWiki, we need to configure its settings. Navigate to the MediaWiki directory and copy the example settings file to a new file named "LocalSettings.php":

cd /var/www/html
cp LocalSettings.php.example LocalSettings.php

Open the "LocalSettings.php" file in your preferred text editor and modify the settings to match your environment. Some of the settings you'll need to update:

$wgSitename       = "My Wiki";
$wgServer         = "http://example.com";
$wgDBname         = "my_wiki";
$wgDBuser         = "wikiuser";
$wgDBpassword     = "wikipassword";
$wgScriptPath     = "";

Save and close the file when you are finished.

Step 8 – Finish installation via browser

With MediaWiki installed and configured, you can complete the installation process by visiting your web server’s IP address or domain name in your web browser. Follow the on-screen instructions from the MediaWiki installer to complete the process.

Conclusion

Congratulations! You’ve now installed MediaWiki on your Debian system. You can now create a new wiki, collaborate with others, and share knowledge.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!