How to Install and Set Up MediaWiki on VPS for Knowledge Management

MediaWiki is a free and open-source wiki software that is highly customizable and used by many organizations and individuals for knowledge management, including Wikipedia. Installing MediaWiki on a Virtual Private Server (VPS) enables you to host your own knowledge base or wiki system.

In this guide, we’ll walk you through the steps to install and set up MediaWiki on a VPS for efficient knowledge management.


Prerequisites

Before proceeding with the installation, make sure that your VPS meets the following requirements:

  1. A VPS running Ubuntu 20.04 or later (or any other compatible Linux distribution).
  2. Root or sudo privileges to execute system commands.
  3. A domain name (optional) for easier access to the wiki.
  4. At least 2 GB of RAM and 1 CPU core (recommended).
  5. Access to the internet to download required packages and dependencies.

Step 1: Update Your VPS

To ensure your server is up to date and secure, start by updating the package lists and upgrading the installed packages:

 
sudo apt update && sudo apt upgrade -y

Step 2: Install Required Dependencies

MediaWiki requires a web server, PHP, and a database to store its data. The most commonly used combination is Apache, PHP, and MySQL/MariaDB.

Install Apache Web Server:

Apache is a widely used web server. Install it with the following command:

 
sudo apt install apache2 -y

Install PHP and Required Extensions:

MediaWiki requires PHP 7.3 or higher along with several extensions. Install PHP and the necessary extensions:

 
sudo apt install php php-mbstring php-xml php-mysql php-intl php-gd php-curl php-zip php-bz2 php-json -y

Install MySQL or MariaDB:

MediaWiki requires a database to store its data. We’ll install MySQL (MariaDB can also be used, as it’s compatible with MySQL):

 
sudo apt install mysql-server -y

Secure the MySQL installation by running the following command and following the on-screen instructions:

 
sudo mysql_secure_installation

Step 3: Create a Database for MediaWiki

Next, we need to create a database that MediaWiki will use.

  1. Log into MySQL:

     
    sudo mysql -u root -p
  2. Create the MediaWiki database:

    sql
     
    CREATE DATABASE mediawiki;
  3. Create a user for MediaWiki:

    sql
     
    CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'strongpassword';
  4. Grant privileges to the user:

    sql
     
    GRANT ALL PRIVILEGES ON mediawiki.* TO 'wikiuser'@'localhost';
  5. Flush privileges and exit MySQL:

    sql
     
    FLUSH PRIVILEGES; EXIT;

Step 4: Download and Install MediaWiki

Now that we’ve installed the required dependencies and created the database, let’s install MediaWiki.

  1. Download the latest MediaWiki release:

    Go to the MediaWiki download page and copy the latest stable release link. Use wget to download it:

     
    wget https://releases.wikimedia.org/mediawiki/1.39/mediawiki-1.39.0.tar.gz
  2. Extract the MediaWiki archive:

     
    tar -xvzf mediawiki-1.39.0.tar.gz
  3. Move the extracted files to the Apache web root:

     
    sudo mv mediawiki-1.39.0 /var/www/html/mediawiki
  4. Set the correct permissions:

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

Step 5: Configure Apache for MediaWiki

To make MediaWiki accessible via the web, you need to configure Apache.

  1. Create a new Apache configuration file for MediaWiki:

     
    sudo nano /etc/apache2/sites-available/mediawiki.conf
  2. Add the following content to the configuration file:

    apache
     
    <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html/mediawiki ServerName yourdomain.com <Directory /var/www/html/mediawiki> AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
  3. Enable the new site and necessary Apache modules:

     
    sudo a2ensite mediawiki.conf sudo a2enmod rewrite sudo systemctl restart apache2

Step 6: Complete the MediaWiki Installation via Web Interface

  1. Open your browser and navigate to your server’s IP address or domain name:

    arduino
     
    http://yourdomain.com

    You will be greeted by the MediaWiki installation page. If you’re using a domain, replace yourdomain.com with your actual domain name.

  2. Choose your language and click Continue.

  3. Check PHP configuration: MediaWiki will verify your PHP setup and database configuration. Ensure all required extensions are installed and enabled. If everything is fine, click Continue.

  4. Configure the Database: Enter the following details:

    • Database type: MySQL
    • Database host: localhost
    • Database name: mediawiki
    • Database user: wikiuser
    • Database password: strongpassword (use the password you created earlier)

    Click Continue.

  5. Configure Wiki Settings: You will now need to set up basic wiki information such as:

    • Wiki name (e.g., "My Knowledge Base")
    • Administrator username, password, and email
  6. Generate the LocalSettings.php file: Once the installation is complete, MediaWiki will generate a LocalSettings.php file. Download this file and upload it to the mediawiki directory:

     
    sudo mv ~/Downloads/LocalSettings.php /var/www/html/mediawiki

Step 7: Finalize the Installation

  1. Set proper permissions for the LocalSettings.php file:

     
    sudo chown www-data:www-data /var/www/html/mediawiki/LocalSettings.php sudo chmod 644 /var/www/html/mediawiki/LocalSettings.php
  2. Restart Apache to apply any changes:

     
    sudo systemctl restart apache2

Step 8: Access Your MediaWiki Wiki

Your MediaWiki installation is now complete. You can access your wiki by navigating to your server’s IP address or domain in a web browser:

arduino
 
http://yourdomain.com

Log in using the administrator credentials you created during the installation process. You can start creating articles, managing users, and configuring your wiki settings from the web interface.


Step 9: Secure Your MediaWiki Installation (Optional but Recommended)

For better security, you should:

  1. Set up SSL (HTTPS): Secure your MediaWiki installation by using Let's Encrypt or any other SSL certificate provider.

    Example using Let’s Encrypt (Certbot):

     
    sudo apt install certbot python3-certbot-apache -y sudo certbot --apache
  2. Regular Backups: Regularly back up your database and MediaWiki files to avoid data loss.

  3. Monitor MediaWiki: Use monitoring tools like UptimeRobot or Prometheus to monitor the health of your VPS and wiki.


Conclusion

You’ve successfully installed and configured MediaWiki on your VPS for knowledge management. Now you can use it to create, organize, and manage your knowledge base. Whether you're using it for internal documentation, project management, or community-driven content, MediaWiki provides a powerful, flexible platform to help you manage information efficiently.

If needed, you can further customize your wiki by installing extensions, themes, and other tools to enhance its functionality.

Was this answer helpful? 0 Users Found This Useful (0 Votes)

Powered by WHMCompleteSolution