Introduction
MediaWiki is free and open-source wiki software and it is the same software used by Wikipedia. It is fully dynamic and runs on a LAMP stack, taking advantage of the PHP language and the MySQL database backend. With easy installation and configuration, MediaWiki is a good solution when you need a familiar, full-featured dynamic wiki engine.
Requirements
LAMP (Apache, PHP, MySQL).
Ubuntu 22.04 or 24.04 / Debian 11 or 12.
Root or sudo privileges.
Installation
Updating System
First things first. Like always, first of all, we recommend to update and upgrade your server.
apt-get update && apt-get upgrade -y
LAMP installation
For starters, you will need to install Apache, PHP and MySQL (LAMP) stack. Do the following:
apt-get install -y apache2 mariadb-server php php-intl php-mbstring php-apcu php-curl php-mysql php-xml
Set up the database
The MediaWiki initial configuration script requires a database name and a database username to store the wiki’s content.
The following commands will create a database named my_wiki
, a user named wikiuser
, and assign permissions for the user on that database.
mysql
CREATE DATABASE my_wiki;
CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'database_password';
GRANT ALL PRIVILEGES ON my_wiki.* TO 'wikiuser'@'localhost' WITH GRANT OPTION;
exit
Installing MediaWiki
To begin, download the latest MediaWiki package. You can find the download location for the releases by visiting the MediaWiki Download Page.
Go to web-accessible DocumentRoot, in our case it is:
cd /var/www/html/
Use wget to download the latest package. During this tutorial's writing version is 1.44.0:
wget https://releases.wikimedia.org/mediawiki/1.44/mediawiki-1.44.0.tar.gz
Decompress the package by using the tar command, as shown below:
tar -xvzf mediawiki-1.44.0.tar.gz
Move the uncompressed mediawiki-1.44.0 directory into your html/
folder, renaming the directory to mediawiki/
in the process
mv mediawiki-1.44.0 mediawiki
The name of the directory beneath the html/
will determine the path to your wiki. In this case, the wiki would be located at mediawiki/
.
The config/
directory inside the mediawiki/
directory needs to allow MediaWiki to write to it during the installation process. Change into the mediawiki/
directory and run the following chmod command:
cd mediawiki
chmod a+w mw-config
Configuration
On your browser go to your_domain/mediawiki and click the “Please set up the wiki first” link. The setup page contains everything you need to complete the installation.
Now proceed with the configuration, enter such information as database name, username, and password, and so on.
After completing the installation form and submitting it, you will arrive at the “MediaWiki Installation” page. An automatic file download should be initiated. Save or open the file.
Now, get back to SSH access on your VPS. Create a LocalSettings.php file:
nano /var/www/html/mediawiki/LocalSettings.php
Upload the contents of the previously saved or opened file to the LocalSettings.php file and save it.
Since the LocalSettings.php file will contain your MySQL password, make sure to restrict access to it:
chown root:www-data /var/www/html/mediawiki/LocalSettings.php
chmod 640 /var/www/html/mediawiki/LocalSettings.php
Conclusion
MediaWiki is now successfully installed and configured! Now you have powerful and at same time easy to use wiki engine.