MediaWiki is free, open-source wiki software that helps users store and organize information and knowledge. It facilitates collaborative editing among multiple users. MediaWiki offers a user-friendly interface, extensibility, revision history, multilingual support, and rich text editing features. As such, many people use it for collaboration projects, knowledge bases, and documentation. If that’s what you’re after, this tutorial will show you exactly how to install MediaWiki on Ubuntu 24.04 servers.
Table of Contents
Prerequisites
- A server with Ubuntu 24.04 as OS
- User privileges: root or non-root user with sudo privileges
Step 1. Update the System
Before installing the software, we must update the system packages to the latest version.
# apt-get update && sudo apt-get upgrade
Step 2. Install MariaDB prerequisites
Firstly, installing the required packets. To do that, execute the following command:
# apt-get install wget software-properties-common dirmngr ca-certificates apt-transport-https -y
Step 3. Install MariaDB
Once the system is updated and the required packets are installed, you can proceed with installing MariaDB with the following command:
# apt-get install mariadb-server mariadb-client
After installation is completed, you can log in to the MySQL command line to create the Mediawiki database and user with the mysql command and execute the following commands:
# mysql
CREATE DATABASE mediawiki;
CREATE USER 'mediawikiuser'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON mediawiki.* TO 'mediawikiuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 4. Install PHP and extensions
Now that we’ve installed the database, you will need to install the PHP 8.3 version for Mediawiki with the required PHP modules with the commands:
# add-apt-repository ppa:ondrej/php
# apt-get install php8.3 php8.3-common php8.3-curl php8.3-intl php8.3-mbstring php8.3-xmlrpc php8.3-mysql php8.3-gd php8.3-curl php8.3-xml php8.3-cli php8.3-imagick php8.3-bcmath php8.3-zip
After the installation of PHP 8.3 is completed, you can proceed to the next step of installing MediaWiki.
Step 5. Install Mediawiki
First, you can navigate to the directory where you want to download MediaWiki and download and unzip it:
# cd /tmp
# wget https://releases.wikimedia.org/mediawiki/1.41/mediawiki-1.41.1.tar.gz
# tar -xvzf /tmp/mediawiki-*.tar.gz
# mkdir /var/lib/mediawiki
# mv mediawiki-*/* /var/lib/mediawiki
Now, you can create a symbolic link from the /var/lib/mediawiki directory to /var/www/html/mediawiki
# ln -s /var/lib/mediawiki /var/www/html/mediawiki
Step 5. Create Nginx Configuration File
Once you’ve installed MediaWiki, you can create your NGINX configuration file by navigating to:
cd /etc/nginx/sites-available/
And creating a Configuration File with the following content:
nano mediawiki.conf
server {
listen 80;
root /var/www/mediawiki
index index.html index.htm index.nginx-debian.html index.php;
server_name your-domain.com;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
location ~ /\.ht {
deny all;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
Now, you can test the Nginx configuration file with the following:
nginx -t
So, if the configuration files are correct, you should receive the below output.
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Finally, you can restart the nginx service now with the command: systemctl restart nginx, and you can access Mediawiki at http://your-domain.com using your favorite browser.
Congratulations! You’ve successfully learned how to install Mediawiki on Ubuntu 24.04. If you still find this setup difficult, you can always sign up for our managed MediaWiki hosting, and our Linux admins will do the rest. We are available 24/7 and ready to help.