Introduction

Mediawiki is an open-source wiki application written in the PHP language. Mediawiki can be used by many companies to develop and manage their wiki pages such as, Wikipedia, Wiktionary and Wikimedia Commons. Mediawiki provides a rich set of features like, multi-language support, user management, sharing and formation, and much more.

In this tutorial, we will learn how to install Mediawiki on Debian 10 server.

Prerequisites

To follow this guide, you'll need a fresh installed Ubuntu 18.04 server, a regular, non-root user with sudo permission, enable a basic firewall to block non-essential ports, 1GB of memory and a valid domain name is pointed to your server IP address.

When you have an account available, log in as your non-root user to begin.

Update The System

First, it is recommended to update your system packages to the latest version. You can update them using the following command:

sudo apt-get update -y
sudo apt-get upgrade -y

Once all the packages are updated, restart your system to apply all the configuration changes.

Install LAMP Server

First, you will need to install Apache web server, MariaDB database server, PHP and other required PHP extensions on your server. You can install all of them by running the following command:

sudo apt-get install apache2 mariadb-server php7.3 libapache2-mod-php7.3 php7.3-common php7.3-mbstring php7.3-xmlrpc php7.3-soap php7.3-gd php7.3-xml php7.3-intl php7.3-mysql php7.3-cli php7.3-zip php7.3-curl unzip wget  -y

Once all the packages are installed, open php.ini file and tweak some settings:

sudo nano /etc/php/7.3/apache2/php.ini

Make the following changes:

/etc/php/7.3/apache2/php.ini

memory_limit = 256M upload_max_filesize = 100M max_execution_time = 360 date.timezone = Asia/Kolkata

Save and close the file. Then, start Apache and MariaDB service and enable them to start on system reboot with the following command:

sudo systemctl start apache2
sudo systemctl start mariadb
sudo systemctl enable apache2
sudo systemctl enable mariadb

Configure Database for Mediawiki

Next, you will need to create a database and user for Mediawiki.

To do so, log in to MariaDB shell with the following command:

mysql -u root -p

Provide your root password when prompt then create a database and user with the following command:

MariaDB [(none)]> CREATE DATABASE mediadb;
MariaDB [(none)]> CREATE USER 'mediauser'@'localhost' IDENTIFIED BY 'password';

Next, grant all the privileges to Mediawiki database with the following command:

MariaDB [(none)]> GRANT ALL ON mediadb.* TO 'mediauser'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

Next, flush the privileges and exit from the MariaDB shell with the following command:

MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;

Install Mediawiki

First, download the latest version of Mediawiki from their official website with the following command:

wget https://releases.wikimedia.org/mediawiki/1.33/mediawiki-1.33.0.tar.gz

Next, extract the downloaded file with the following command:

tar -xvzf mediawiki-1.33.0.tar.gz

Next, copy the extracted directory to Apache web root directory:

sudo cp -r mediawiki-1.33.0 /var/www/html/mediawiki

Next, give proper permissions to the mediawiki directory with the following command:

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

Configure Apache for Mediawiki

Next, you will need to create an Apache virtual host file for Mediawiki. You can create it with the following command:

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

Add the following lines:

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

<VirtualHost *:80> ServerAdmin admin@example.com DocumentRoot /var/www/html/mediawiki/ ServerName example.com <Directory /var/www/html/mediawiki/> Options +FollowSymLinks AllowOverride All </Directory> ErrorLog /var/log/apache2/media-error_log CustomLog /var/log/apache2/media-access_log common </VirtualHost>

Save and close the file when you are finished. Then, enable the virtual host and rewrite module with the following command:

sudo a2ensite mediawiki.conf
sudo a2enmod rewrite

Finally, restart Apache web service to apply all the configuration changes:

sudo systemctl restart apache2

Access Mediawiki Web Interface

Now, open your web browser and type the URL http://example.com. You should see the following page: mediawiki-welcome Now, click on the set up the wiki. You should see the following page:

mediawiki-language

Select your language and click on the Continue. You should see the Copyright and Terms page: mediawiki-copyright

Next, click on the Continue. You should see the following page: mediawiki-database

Now, provide your database name, username and password. Then, click on the Continue. You should see the following page: mediawiki-storage-enginemediawiki-storage-engine

Now, select InnoDB storage engine and click on the Continue. You should see the following page:

mediawiki-sitenamemediawiki-sitename mediawiki-admin

Now, provide your Wiki name, administrator username and password. Then, click on the Continue. You should see the following page: mediawiki-settings1 mediawiki-settings2 mediawiki-settings3

Now, select any required settings and click on the Continue. You should see the following page: mediawiki-installation Now, click on the Continue to start the installation. You should see the following page: mediawiki-installation-continue

Now, click again on the Continue button. Once the installation has been completed, you should see the following page: mediawiki-localsettings

Now, download the LocalSettings.php file and put it on the Mediawiki root directory. Then, click on the enter your wiki. You should see the Mediawiki default page: mediawiki-dashboard

Read more about: DebianOperating System