How to Install MediaWiki Linux | Setup Your Server Quickly

Technicians communicating Mediawiki setup methods guiding customers through simple install MediaWiki Linux steps

When creating knowledge bases for use at IOFLOOD, we prefer an organized MediaWiki setup. MediaWiki, the software behind Wikipedia, offers powerful tools for content management. Today’s article will cover all methods to install MediaWiki on Linux to help our cloud server hosting customers looking to deploy and manage their own wikis.

In this tutorial, we will guide through methods to install MediaWiki Linux. We will show you methods for both APT and YUM-based distributions, delve into compiling MediaWiki from source, installing a specific version, and finally, how to use the MediaWiki command and ensure it’s installed correctly.

So, let’s dive in and begin installing MediaWiki!

TL;DR: How To Install MediaWiki on Linux?

You can star a MediaWiki setup Linux by downloading the latest version of MediaWiki from the official website, extracting the files, and running the installation script. Here’s a quick example:

sudo apt-get update
sudo apt-get install apache2 php libapache2-mod-php php-mysql mysql-server
wget https://releases.wikimedia.org/mediawiki/1.42/mediawiki-1.42.1.tar.gz
tar -xvzf mediawiki-1.42.1.tar.gz
sudo mv mediawiki-1.42.1 /var/www/html/mediawiki
# Complete the setup by accessing MediaWiki via your web browser.

This is a basic way to install MediaWiki on Linux, but there’s much more to learn about installing and configuring MediaWiki to suit your needs. Continue reading for more detailed information and advanced installation options.

Intro: MediaWiki Setup Guide

MediaWiki is a free and open-source wiki software, written in PHP. It’s the software behind Wikipedia, and many other wikis around the world. If you’re looking to create a collaborative platform where users can create, edit, and organize web content, MediaWiki is an excellent choice.

Now, let’s get into how to install MediaWiki on Linux. We will cover installations using apt and yum package managers.

Installing MediaWiki with APT

If you’re using a Debian-based Linux distribution, such as Ubuntu, you can use the APT package manager to install MediaWiki. Here’s how you can do it:

# Update your package lists
sudo apt-get update

# Install MediaWiki
sudo apt-get install mediawiki

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# The following additional packages will be installed:
#  mediawiki-math
# Suggested packages:
#  mediawiki-extensions-base
# The following NEW packages will be installed:
#  mediawiki mediawiki-math
# 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
# Need to get 0 B/2,843 kB of archives.
# After this operation, 13.2 MB of additional disk space will be used.
# Do you want to continue? [Y/n]

The sudo apt-get update command updates your package lists to ensure you’re installing the latest version. After that, sudo apt-get install mediawiki installs MediaWiki on your system. The output shows the installation progress and any additional packages that are installed.

Install MediaWiki Linux with YUM

If you’re using a Red Hat-based Linux distribution, such as CentOS or Fedora, you can use the YUM package manager to install MediaWiki. Here’s how:

# Update your package lists
sudo yum check-update

# Install MediaWiki
sudo yum install mediawiki

# Output:
# Loaded plugins: fastestmirror, langpacks
# Loading mirror speeds from cached hostfile
#  * base: mirror.vcu.edu
#  * extras: mirror.vcu.edu
#  * updates: mirror.vcu.edu
# Resolving Dependencies
# --> Running transaction check
# ---> Package mediawiki.x86_64 0:1.23.14-1.el7 will be installed
# --> Finished Dependency Resolution
# Dependencies Resolved
# ==================================================================
#  Package     Arch     Version         Repository      Size
# ==================================================================
# Installing:
#  mediawiki   x86_64   1.23.14-1.el7   base           2.4 M
# Transaction Summary
# ==================================================================
# Install  1 Package
# Total download size: 2.4 M
# Installed size: 13 M
# Is this ok [y/d/N]: y

The sudo yum check-update command updates your package lists, and sudo yum install mediawiki installs MediaWiki on your system. The output shows the installation progress and any additional packages that are installed.

With MediaWiki installed, you’re now ready to start creating and managing your own wiki site on your Linux server.

MediaWiki Setup from Source Code

Sometimes, you may want to install MediaWiki from source code. This allows you to get the latest features and bug fixes, and it can be a great learning experience. Here’s how you can do it:

# Download the latest MediaWiki source code
wget https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.1.tar.gz

# Extract the source code
tar xvzf mediawiki-*.tar.gz

# Navigate into the extracted directory
cd mediawiki-1.35.1

# Run the installation script
php install.php

# Output:
# Checking environment...
# PHP 7.3.27-1~deb10u1: ok
# PHP server API is apache2handler; ok, using pretty URLs (index.php/Page_Title)
# Have XML / Latin1-UTF-8 conversion support.
# Have PHP 7.3.27-1~deb10u1.
# Have the InnoDB storage engine for MySQL.
# Checking MediaWiki version requirements...
# MediaWiki 1.35.1 installation successful.

In this example, we first downloaded the latest MediaWiki source code using the wget command. We then extracted the source code using the tar command. After navigating into the extracted directory with the cd command, we ran the installation script with php install.php. The output shows the progress of the installation and any important information.

How to Install MediaWiki Versions

Depending on your needs, you might want to install a different version of MediaWiki. This could be because of specific features, bug fixes, or compatibility reasons. Here’s how you can install a specific version of MediaWiki from source and using package managers.

Installing MediaWiki Specific Version from Source

# Download a specific version of MediaWiki
wget https://releases.wikimedia.org/mediawiki/1.34/mediawiki-1.34.4.tar.gz

# Extract the source code
tar xvzf mediawiki-*.tar.gz

# Navigate into the extracted directory
cd mediawiki-1.34.4

# Run the installation script
php install.php

# Output:
# Checking environment...
# PHP 7.3.27-1~deb10u1: ok
# PHP server API is apache2handler; ok, using pretty URLs (index.php/Page_Title)
# Have XML / Latin1-UTF-8 conversion support.
# Have PHP 7.3.27-1~deb10u1.
# Have the InnoDB storage engine for MySQL.
# Checking MediaWiki version requirements...
# MediaWiki 1.34.4 installation successful.

In this example, we downloaded a specific version of MediaWiki (1.34.4) using the wget command. We then extracted the source code, navigated into the extracted directory, and ran the installation script. The output shows that MediaWiki 1.34.4 was successfully installed.

Install MediaWiki Version with APT

If you’re using a Debian-based Linux distribution, you can use the APT package manager to install a specific version of MediaWiki. Here’s how:

# Update your package lists
sudo apt-get update

# Install a specific version of MediaWiki
sudo apt-get install mediawiki=1.34.4-1

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# The following additional packages will be installed:
#  mediawiki-math
# Suggested packages:
#  mediawiki-extensions-base
# The following NEW packages will be installed:
#  mediawiki mediawiki-math
# 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
# Need to get 0 B/2,843 kB of archives.
# After this operation, 13.2 MB of additional disk space will be used.
# Do you want to continue? [Y/n]

In this example, we first updated our package lists with sudo apt-get update. We then installed a specific version of MediaWiki (1.34.4-1) with sudo apt-get install mediawiki=1.34.4-1. The output shows the installation progress and any additional packages that are installed.

Installing a Specific Version with YUM

If you’re using a Red Hat-based Linux distribution, you can use the YUM package manager to install a specific version of MediaWiki. Here’s how:

# Update your package lists
sudo yum check-update

# Install a specific version of MediaWiki
sudo yum install mediawiki-1.34.4-1

# Output:
# Loaded plugins: fastestmirror, langpacks
# Loading mirror speeds from cached hostfile
#  * base: mirror.vcu.edu
#  * extras: mirror.vcu.edu
#  * updates: mirror.vcu.edu
# Resolving Dependencies
# --> Running transaction check
# ---> Package mediawiki.x86_64 0:1.34.4-1.el7 will be installed
# --> Finished Dependency Resolution
# Dependencies Resolved
# ==================================================================
#  Package     Arch     Version         Repository      Size
# ==================================================================
# Installing:
#  mediawiki   x86_64   1.34.4-1.el7   base           2.4 M
# Transaction Summary
# ==================================================================
 # ==================================================================
# Install  1 Package
# Total download size: 2.4 M
# Installed size: 13 M
# Is this ok [y/d/N]: y

In this example, we first updated our package lists with sudo yum check-update. We then installed a specific version of MediaWiki (1.34.4-1) with sudo yum install mediawiki-1.34.4-1. The output shows the installation progress and any additional packages that are installed.

Key Changes in MediaWiki Versions

Different versions of MediaWiki come with different features and bug fixes. Here’s a comparison of some key changes between versions:

VersionKey Changes
1.35.1Latest release, includes all the latest features and bug fixes
1.34.4Older release, but still supported and includes many features

Use and Verify MediaWiki Install

Once you’ve installed MediaWiki, you’ll want to know how to use it and verify that it’s installed correctly.

Basic Usage of MediaWiki

Here’s a basic example of how to use MediaWiki to create a new page:

# Navigate to your MediaWiki directory
cd /var/www/html/mediawiki

# Create a new page
php maintenance/edit.php --summary "Creating a new page" --bot "MyPage" "This is the content of my new page."

# Output:
# Page [[MyPage]] saved

In this example, we navigated to our MediaWiki directory with cd /var/www/html/mediawiki. We then created a new page with php maintenance/edit.php --summary "Creating a new page" --bot "MyPage" "This is the content of my new page.". The output shows that the new page was successfully created.

Verifying the MediaWiki Setup

Here’s how you can verify that MediaWiki is installed correctly:

# Navigate to your MediaWiki directory
cd /var/www/html/mediawiki

# Run the version script
php maintenance/version.php

# Output:
# MediaWiki 1.35.1
# PHP 7.3.27-1~deb10u1 (apache2handler)
# MariaDB 10.3.27-MariaDB-0+deb10u1

In this example, we navigated to our MediaWiki directory and ran the version script with php maintenance/version.php. The output shows the MediaWiki version, PHP version, and MariaDB version, confirming that MediaWiki is installed correctly.

Alternate MediaWiki Install Methods

While installing MediaWiki using a package manager or from source is common, there are alternative methods you may find useful. Let’s explore how to install MediaWiki using Docker and manual installation.

Docker MediaWiki Install

Docker is a popular platform for deploying applications in containers. Here’s how you can install MediaWiki using Docker:

# Pull the latest MediaWiki Docker image
sudo docker pull mediawiki

# Run a new MediaWiki container
sudo docker run --name my-mediawiki -p 8080:80 -d mediawiki

# Output:
# Unable to find image 'mediawiki:latest' locally
# latest: Pulling from library/mediawiki
# 69692152171a: Pull complete
# Digest: sha256:4d13b4014e286d01870c17df08b3a1f9e999e97e2d1b2d1d3da692b4a71a70a6
# Status: Downloaded newer image for mediawiki:latest
# 1d3e7a6803e7b9061fa34624b49a5d38b8672d4f4a9191a5243c4861f578223e

In this example, we first pulled the latest MediaWiki Docker image with sudo docker pull mediawiki. We then ran a new MediaWiki container with sudo docker run --name my-mediawiki -p 8080:80 -d mediawiki. The output shows the progress of the Docker image download and the ID of the new MediaWiki container.

Docker installation provides isolation from the host system and allows easy version management. However, it requires understanding of Docker and might be overkill for simple use cases.

Manual MediaWiki Install

For complete control over the installation process, you can manually install MediaWiki. Here’s how you can do it:

# Download the latest MediaWiki source code
wget https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.1.tar.gz

# Extract the source code
tar xvzf mediawiki-*.tar.gz

# Move the extracted files to your web directory
sudo mv mediawiki-1.35.1/* /var/www/html/

# Output:
# 'mediawiki-1.35.1/README' -> '/var/www/html/README'
# 'mediawiki-1.35.1/RELEASE-NOTES-1.35' -> '/var/www/html/RELEASE-NOTES-1.35'
# ...

In this example, we first downloaded the latest MediaWiki source code with wget. We then extracted the source code with tar, and moved the extracted files to our web directory with sudo mv. The output shows the progress of moving the files.

Manual installation gives you the most control and understanding of the process, but it requires more steps and a higher level of technical knowledge.

In conclusion, while package managers and source installations are common, Docker and manual installations offer alternative methods that might better suit your needs. Consider your technical knowledge, needs, and the specific advantages and disadvantages of each method when choosing how to install MediaWiki.

Troubleshooting MediaWiki Installs

Like any software installation, installing MediaWiki on Linux can sometimes run into problems. Here are a few common issues you might encounter, along with their solutions.

Error: ‘php’ command not found

If you see an error message like this when trying to run the MediaWiki installation script, it means PHP is not installed on your system.

# Run the installation script
php install.php

# Output:
# bash: php: command not found

In this example, trying to run php install.php resulted in the error message bash: php: command not found. To fix this, you need to install PHP. Here’s how you can do it on Ubuntu:

# Update your package lists
sudo apt-get update

# Install PHP
sudo apt-get install php

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# The following additional packages will be installed:
#  php-common php7.2-cli php7.2-json php7.2-opcache php7.2-readline
# Suggested packages:
#  php-pear
# The following NEW packages will be installed:
#  php php-common php7.2-cli php7.2-json php7.2-opcache php7.2-readline
# 0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
# Need to get 1,374 kB of archives.
# After this operation, 6,807 kB of additional disk space will be used.
# Do you want to continue? [Y/n]

In this example, we first updated our package lists with sudo apt-get update. We then installed PHP with sudo apt-get install php. The output shows the installation progress and any additional packages that were installed.

Error: ‘wget’ command not found

If you see an error message like this when trying to download MediaWiki, it means the wget command is not installed on your system.

# Download MediaWiki
wget https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.1.tar.gz

# Output:
# bash: wget: command not found

In this example, trying to download MediaWiki with wget resulted in the error message bash: wget: command not found. To fix this, you need to install wget. Here’s how you can do it on Ubuntu:

# Update your package lists
sudo apt-get update

# Install wget
sudo apt-get install wget

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# The following NEW packages will be installed:
#  wget
# 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
# Need to get 316 kB of archives.
# After this operation, 905 kB of additional disk space will be used.
# Do you want to continue? [Y/n]

In this example, we first updated our package lists with sudo apt-get update. We then installed wget with sudo apt-get install wget. The output shows the installation progress.

Considerations When Installing MediaWiki

When installing MediaWiki, there are a few key considerations to keep in mind:

  • Server Requirements: MediaWiki requires a web server, PHP, and a database server to function. Make sure your server meets these requirements before attempting to install MediaWiki.
  • Permissions: Make sure you have the necessary permissions to install software on your server. This typically means you need to be logged in as a user with sudo privileges.
  • Version Compatibility: Different versions of MediaWiki may require different versions of PHP and the database server. Make sure to check the compatibility before installing.
  • Security: After installing MediaWiki, make sure to secure your installation. This can include setting strong passwords, limiting permissions, and keeping your software up to date.

By keeping these considerations in mind, you can ensure a smooth and successful installation of MediaWiki on your Linux server.

Understanding Your MediaWiki Install

Before diving into the installation process, it’s essential to understand the fundamentals of MediaWiki and Linux. This knowledge will help you grasp the installation process better and manage your MediaWiki site effectively.

What is MediaWiki?

MediaWiki is a free and open-source software written in PHP. It’s primarily designed for creating and managing wiki-style content. MediaWiki is the software behind Wikipedia, one of the world’s largest online encyclopedias, and many other wikis worldwide.

The architecture of MediaWiki is designed to be robust, scalable, and customizable. It supports a wide range of content formats, includes powerful search capabilities, and offers various extensions for added functionality. MediaWiki uses a database to store pages, metadata, user details, and more.

# MediaWiki's directory structure example
ls /var/www/html/mediawiki

# Output:
# api.php  cache  img_auth.php  opensearch_desc.php  thumb.php
# autoload.php  CREDITS  includes  profileinfo.php  trackback.php
# cache_messages.php  docs  index.php  redirect.php  UPGRADE
# COPYING  extensions  INSTALL  RELEASE-NOTES-1.35  vendor

The above command lists the directory structure of a typical MediaWiki installation. You can see various PHP scripts like index.php (the main script), directories like extensions (for additional functionalities), and files like INSTALL and UPGRADE (providing installation and upgrade instructions).

Linux and Server Management Basics

Linux is a free and open-source operating system that’s widely used in server environments due to its stability, security, and flexibility. Understanding the basics of Linux and server management is crucial when installing and managing software like MediaWiki.

Linux uses a command-line interface, known as the shell, for performing tasks. Commands like ls (list directory contents), cd (change directory), mv (move or rename files), and wget (download files from the internet) are often used during the installation process.

# Linux command examples
ls /var/www/html/ # Lists the contents of the web directory

# Output:
# index.html  mediawiki

cd /var/www/html/mediawiki # Changes the current directory to the MediaWiki directory

wget https://example.com/file.tar.gz # Downloads a file from the internet

In the above example, we used ls to list the contents of the web directory, cd to navigate to the MediaWiki directory, and wget to download a file.

When managing a Linux server, it’s also important to understand concepts like file permissions, package management (using tools like APT or YUM), and process management. These concepts play a key role in installing, configuring, and troubleshooting software on a server.

With a solid understanding of MediaWiki and Linux, you’re now better equipped to install MediaWiki on a Linux server and manage your MediaWiki site effectively.

The Relevance of MediaWiki

MediaWiki is more than just a tool for creating wiki-style content. It’s a powerful platform that can play a significant role in web server management. By using MediaWiki, you can create a central repository of information that’s easy to access and update. This can be particularly useful for documenting server configurations, tracking changes, and collaborating with team members.

MediaWiki in Content Management

As a content management system (CMS), MediaWiki offers a range of features that make it easy to create, edit, and organize content. It supports a wide variety of content formats, including text, images, and multimedia. Its powerful search capabilities make it easy to find the information you need. And with its extensive range of extensions, you can add even more functionality to your MediaWiki site.

Next Steps After MediaWiki Install

While installing and using MediaWiki is a significant step, there are other related concepts that you might find useful to explore. These include database management and server security.

Database Management

MediaWiki uses a database to store its data. Understanding how to manage this database can help you optimize your MediaWiki site’s performance, back up and restore data, and troubleshoot issues. You might want to explore topics like SQL (the language used to interact with databases), database optimization, and backup and recovery techniques.

Server Security

Securing your MediaWiki site is crucial. This involves securing your Linux server, your web server, and MediaWiki itself. You might want to explore topics like Linux security, HTTPS (secure communication over a network), and MediaWiki’s built-in security features.

Further Resources for Mastering MediaWiki

For those who wish to delve deeper into MediaWiki and related topics, here are some valuable resources:

  1. The Official MediaWiki Guide: This guide covers everything from getting started with MediaWiki to advanced topics like managing users and permissions.

  2. The Linux Command Line: A Complete Introduction: This book is a comprehensive introduction to using the Linux command line, which is crucial when installing and managing software like MediaWiki on a Linux server.

  3. Web Application Security, A Beginner’s Guide: This book provides a solid introduction to web application security, including topics relevant to securing a MediaWiki site.

Recap: How to Install MediaWiki

In this comprehensive guide, we’ve delved into the process of installing MediaWiki on a Linux server. We’ve explored the steps to set up your own Wiki site using MediaWiki, a robust and customizable platform.

We began with the basics, learning how to install MediaWiki using package managers like APT and YUM. We then advanced to more complex installation methods, such as installing MediaWiki from source and installing specific versions. Along the way, we tackled common issues you might encounter during the installation and provided solutions for each.

We also explored alternative approaches to installation, such as using Docker and manual installation. These methods provide greater control and isolation from the host system, which can be beneficial in certain scenarios.

Here’s a quick comparison of the methods we’ve discussed:

MethodProsCons
Package Manager (APT, YUM)Simple, straightforwardLimited to available packages
Source InstallationComplete control, can install specific versionsMore complex, requires compilation
DockerIsolation from host system, easy version managementRequires understanding of Docker
Manual InstallationComplete control over the processMore steps, requires higher technical knowledge

Whether you’re just starting out with MediaWiki or looking to level up your server management skills, we hope this guide has given you a deeper understanding of MediaWiki and its installation process.

With MediaWiki, you can create a collaborative platform for users to create, edit, and organize web content. Now, you’re well-equipped to take the first step into setting up your own Wiki site. Happy coding!