Let’s learn the steps to install MediaWiki on Ubuntu 22.04 LTS Jammy JellyFish server to run your own Wiki system like Wikipedia.
Mediawiki is open source content management software in the form of a wiki system that makes websites such as Wikipedia.org possible. With the help of MediaWiki, you can not only read a website with other users, but also edit it in real time. You can quickly and easily put texts, photos and movies on your Mediawiki page.
With the help of MediaWiki, you can quickly edit, delete or publish content on your website. Mediawiki keeps all currently saved changes without deleting previous versions. If you accidentally deleted important content, you can restore it at any time. It allows joint editing of content and is suitable, among other things, for building knowledge databases or journal collections.
Unlike other content management systems, MediaWiki offers few design options for website layout and design. The main function, on the other hand, is an editing mode for each wiki page, which also allows a newcomer to modify the text and content of the page without much training.
Steps to Install MediaWiki on Ubuntu 22.04 LTS Server
The steps given here can also be used for other versions of Ubuntu server or desktop such as 20.04/18.04, including other similar systems.
1. Update Ubuntu 22.04 LTS
First, run the system update and upgrade command to ensure that your system packages and APT index repository cache are in their latest state.
sudo apt update && sudo apt upgrade
2. Install Apache and PHP
We need Apache web server, PHP and MySQL stack on our system to install MediaWiki on Ubuntu 22.04 server. However, instead of MySQL, here we use its MariaDB fork.
sudo apt install apache2
To make sure the web server service is running in the background.
sudo systemctl enable --now apache2
To check the status:
systemctl status apache2 --no-page -l
Install PHP and required extensions
To have the latest version of PHP, add the Ondrej repository:
sudo add-apt-repository ppa:ondrej/php
Run the system update command:
sudo apt update
Use APT to get PHP
sudo apt install imagemagick php-fpm php-intl php-xml php-curl php-gd php-mbstring php-mysql php-mysql php-apcu php-zip
To note: if you have multiple versions of PHP, replace the * with the version in the following lines that you want to use for Mediawiki and set as default on your system.
sudo nano /etc/php/*/fpm/php.ini
Find and change the values in the following lines as shown below:
file_uploads = On allow_url_fopen = On upload_max_filesize = 64M memory_limit = 256M max_execution_time = 600 date.timezone = America/Chicago
Once you are done editing, save the file using CTRL+Ohit Walk in button, then quit the file editor- CTRL+X.
Now restart PHP-FPM:
sudo systemctl restart php*-fpm.service
3. Install MariaDB and create a new database
Although you can use MySQL or PostgreSQL, here we are using the MariaDB fork of MySQL to establish a database server for MediaWiki. Follow the given commands to configure MariaDB and create a database for this open source Wiki platform.
sudo apt install mariadb-server
Once the installation is complete, secure your database by setting a root password and removing unnecessary access.
The questions asked will be asked by the system, the sample answers are also given below:
Enter current password for root (enter for none): Press ENTER Set root password? [Y/n]: Y New password: Set-your-new-password Re-enter new password: Set-your-new-password Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y
Once the process of securing the database server is complete, let’s enable and start its service:
sudo systemctl enable --now mariadb
To check the status:
sudo systemctl status mariadb --no-pager
Create a database for MediaWiki
CREATE DATABASE wikidb;
CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON wikidb.* TO 'wikiuser'@'localhost' WITH GRANT OPTION;
To note: Replace wikidb with the name of the database you want to give, likewise wiki user with username and strong password with the password you want to set.
4. Download the MediaWiki file
MediaWiki installation files cannot be downloaded and configured directly using the APT package manager. To get it we have to download it manually from the MediaWiki official websitefollow the page link to visit.
There, right click on the .Tar.GZ link and copy the link address.
Go back to your command terminal from where you access the Ubuntu 22.04 server and use the
wget command to download MediaWiki files.
wget -O mediawiki.tar.gz paste-copied-link
wget -O mediawiki.tar.gz https://releases.wikimedia.org/mediawiki/1.37/mediawiki-1.37.2.tar.gz
Extract the file, once downloaded:
sudo tar -zxvf mediawiki.tar.gz
Create a directory for MediaWiki in Webroot
sudo mkdir -p /var/www/html/wiki
Move the extracted folder files there:
sudo mv mediawiki*/* /var/www/html/wiki
Change the owner of the MediaWiki directory to ‘www-data‘ user and group:
chown -R www-data:www-data /var/www/html/wiki
5. Install MediaWiki on Ubuntu 22.04 LTS
After completing all the steps above, let’s start the MediaWiki web installation to finalize the process of setting up MediaWiki on the Ubuntu server.
To do this, open your local browser and point it to the domain or IP address of the Ubuntu server where you are installing MediaWiki as follows:
http://server-ip/wiki or http://domain.com/wiki
If all goes well, you will get the initial window to start the wiki setup process. Click on the “Configure the wiki” link.
Select the language in which you want to install the MediaWiki, if it is outside of English otherwise just click the “Continue” button.
Click the Continue button to agree to the terms.
Add database details:
We have created a database for use with MediaWiki in this tutorial, so add the details of it such as the database name, username and password you have.
If the database details provided are correct, you will have the Database Settings page, leave the selected items on this page as they are and move forward using the Continue button.
Select user rights for a profile as needed.
If all MediaWiki requirements are met, click the “Continue” button.
Soon the installation will be completed and the system will generate a “LocalSettings.php” which contains all the configuration you have done. Make sure you’ve downloaded it to your system, then upload it to the MediaWiki root directory we created, i.e.
You can use an FTP client or a file manager if you are using a hosting service.
After downloading and moving the file to the Wiki root folder, grant permissions to the Apache user:
chown www-data:www-data /var/www/html/wiki/LocalSettings.php
Finally, click on the Enter your wiki link to go to main page of MediaWiki installed and running on Ubuntu 22.04 LTS Jammy.
For more information on this topic and to understand how MediaWiki works in detail, see the official documentation.
NGINX vs Apache: Comparison of Web Servers to Host Your Website
How to Install Vaultwarden on Ubuntu 22.04 LTS Jammy
How to reset root password in Debian 11 Bullseye