MediaWiki

How To Install MediaWiki on Ubuntu 24.04

If you’re looking to set up a wiki platform for collaboration, documentation, or knowledge sharing, MediaWiki is one of the most robust and flexible options available. Used by Wikipedia and many other projects, it is a free and open-source software that allows users to create and edit content collaboratively. In this blog post, we’ll guide you through the steps to install MediaWiki on Ubuntu 24.04.

Prerequisites

Before you begin the installation, ensure you have the following:

  • A server running Ubuntu 24.04.
  • Root or sudo access to the server.
  • Basic knowledge of the terminal.

Step 1: Update Your System

Start by updating your package list to make sure you have the latest updates. Open your terminal and execute:

sudo apt update
sudo apt upgrade -y

Step 2: Install Necessary Dependencies

MediaWiki relies on a web server, PHP, and a database management system. For this tutorial, we’ll use Apache as the web server and MySQL as the database. Install the necessary packages by running:

sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring php-intl php-json php-curl unzip -y

Step 3: Configure MySQL Database for MediaWiki

Next, you need to set up a database for MediaWiki. Open the MySQL shell by typing:

sudo mysql -u root -p

Create a new database and user for MediaWiki:

CREATE DATABASE mediawiki;
CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'secure_password';
GRANT ALL PRIVILEGES ON mediawiki.* TO 'wikiuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Be sure to replace 'secure_password' with a strong password of your choosing.

Step 4: Download MediaWiki

Go to the official MediaWiki download page to find the latest version. At the time of writing, it is:

cd /tmp
wget https://releases.wikimedia.org/mediawiki/1.39/mediawiki-1.39.1.tar.gz

After downloading, extract the files:

tar -xvzf mediawiki-1.39.1.tar.gz

Now move the extracted files to the web server root directory:

sudo mv mediawiki-1.39.1 /var/www/html/mediawiki

Step 5: Configure Permissions

Set the correct permissions for the MediaWiki directory:

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

Step 6: Configure Apache for MediaWiki

Create a new configuration file for your MediaWiki site:

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

Add the following lines to configure the site:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/mediawiki
    ServerName example.com

    <Directory /var/www/html/mediawiki>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/mediawiki_error.log
    CustomLog ${APACHE_LOG_DIR}/mediawiki_access.log combined
</VirtualHost>

Remember to replace example.com with your domain name. Save and close the file.

Enable the MediaWiki site configuration:

sudo a2ensite mediawiki.conf

Step 7: Enable Rewrite Module

MediaWiki requires the Apache mod_rewrite module to function correctly, so enable it:

sudo a2enmod rewrite

Finally, restart Apache to apply all changes:

sudo systemctl restart apache2

Step 8: Complete the Installation via Web Interface

Open your web browser and navigate to your domain name or server’s IP address (e.g., http://example.com). You should see the MediaWiki installation page.

  1. Follow the on-screen instructions.
  2. Enter the database details you created earlier (database name: mediawiki, username: wikiuser, password: your password).
  3. Complete the configuration settings, including the logo, default language, and administrator account setup.
  4. Download the generated LocalSettings.php file when prompted and place it in the MediaWiki directory:
sudo mv ~/Downloads/LocalSettings.php /var/www/html/mediawiki

Ensure the right permissions on the LocalSettings.php file:

sudo chown www-data:www-data /var/www/html/mediawiki/LocalSettings.php

Step 9: Secure Your Installation

At this point, MediaWiki is installed. To enhance security, consider the following steps:

  1. Secure your MySQL installation:
   sudo mysql_secure_installation
  1. Enable SSL (optional): If you want to secure your site, consider enabling SSL using Let’s Encrypt or another certificate authority.
  2. Regular backups: Regularly back up your MediaWiki database and files.

Conclusion

Congratulations! You have successfully installed MediaWiki on Ubuntu 24.04. With its powerful features and flexibility, you can now start creating and managing your wiki content. If you face any challenges or have questions, feel free to leave a comment below! Happy wiking!


For more tutorials on server management and software installations, stay tuned to Greenhost.Cloud’s blog!