RHEL BasedRocky Linux

How To Install MediaWiki on Rocky Linux 9

Install MediaWiki on Rocky Linux 9

MediaWiki, the powerful open-source wiki software that powers Wikipedia, has become an indispensable tool for knowledge management and collaborative content creation. Whether you’re setting up a corporate knowledge base or a community-driven information hub, installing MediaWiki on a robust platform like Rocky Linux 9 ensures a stable and secure foundation for your wiki project. This guide will walk you through the process of installing MediaWiki on Rocky Linux 9, providing detailed instructions, troubleshooting tips, and best practices to ensure a smooth setup.

Rocky Linux 9, known for its stability and security, offers an excellent environment for hosting MediaWiki. As a community-driven, enterprise-grade operating system, it provides the reliability needed for running critical applications like wikis. By following this guide, you’ll be able to harness the power of MediaWiki on a solid Linux distribution, creating a scalable and efficient wiki platform.

In this comprehensive tutorial, we’ll cover everything from system prerequisites to post-installation optimization. We’ll guide you through each step of the process, ensuring that you have all the information needed to successfully deploy MediaWiki on your Rocky Linux 9 server. Let’s dive in and start building your wiki!

1. Prerequisites for Installing MediaWiki on Rocky Linux 9

Before we begin the installation process, it’s crucial to ensure that your system meets the necessary requirements and that you have all the required components in place. This preparation will help avoid potential roadblocks during the installation.

System Requirements

MediaWiki is relatively lightweight, but to ensure optimal performance, your Rocky Linux 9 server should meet or exceed these specifications:

  • CPU: 1 GHz processor (2 GHz or higher recommended for larger wikis)
  • RAM: 512 MB minimum (2 GB or more recommended)
  • Storage: 5 GB of free disk space (more for larger wikis and file uploads)

These requirements may vary depending on the expected traffic and the size of your wiki. For high-traffic sites or extensive wikis, consider allocating more resources.

Software Versions

MediaWiki requires specific software versions to function correctly. Rocky Linux 9 comes with compatible versions of the required software, but it’s essential to verify:

  • PHP: Version 7.4 or higher (Rocky Linux 9 includes PHP 8.0)
  • MariaDB: Version 10.3 or higher (Rocky Linux 9 includes MariaDB 10.5)
  • Apache: Version 2.4 (included in Rocky Linux 9)

Access Requirements

To install MediaWiki, you’ll need:

  • Root access or sudo privileges on your Rocky Linux 9 server
  • SSH access to the server for command-line operations

Dependencies

MediaWiki relies on several key components and PHP extensions. We’ll install these during the process, including:

  • Apache web server
  • MariaDB database server
  • PHP and essential extensions (php-mbstring, php-intl, php-xml, php-json, php-mysqlnd)

Before proceeding with the installation, it’s crucial to update your Rocky Linux 9 system to ensure you have the latest security patches and software versions. This step helps prevent compatibility issues and enhances the overall security of your server.

2. Step-by-Step Installation Process

Now that we’ve covered the prerequisites, let’s dive into the installation process. We’ll break this down into manageable steps to ensure a smooth setup of MediaWiki on your Rocky Linux 9 server.

2.1 Updating the System and Installing Dependencies

First, let’s update the system and install the necessary dependencies:

  1. Open a terminal and connect to your Rocky Linux 9 server via SSH.
  2. Update the system packages:
    sudo dnf update -y
  3. Install Apache, MariaDB, PHP, and required PHP extensions:
    sudo dnf install httpd mariadb-server php php-mbstring php-intl php-json php-xml php-mysqlnd -y
  4. Start and enable Apache and MariaDB services:
    sudo systemctl start httpd mariadb
    sudo systemctl enable httpd mariadb

These commands ensure that your system is up-to-date and that all necessary software is installed and running.

2.2 Configuring MariaDB for MediaWiki

Next, we’ll set up the database for MediaWiki:

  1. Secure your MariaDB installation:
    sudo mysql_secure_installation

    Follow the prompts to set a root password and remove insecure default settings.

  2. Log in to MariaDB as root:
    sudo mysql -u root -p
  3. Create a database and user for MediaWiki:
    CREATE DATABASE mediawiki;
    CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'your_strong_password';
    GRANT ALL PRIVILEGES ON mediawiki.* TO 'wikiuser'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;

    Replace ‘your_strong_password’ with a secure password of your choice.

This setup creates a dedicated database and user for MediaWiki, enhancing security by isolating the application’s data.

2.3 Downloading and Extracting MediaWiki

Now, let’s download and set up the MediaWiki files:

  1. Download the latest stable version of MediaWiki:
    wget https://releases.wikimedia.org/mediawiki/1.42/mediawiki-1.42.1.tar.gz
  2. Extract the files to the web directory:
    sudo tar -xvzf mediawiki-1.42.1.tar.gz -C /var/www/
    sudo mv /var/www/mediawiki-1.42.1 /var/www/mediawiki
  3. Set the correct ownership and permissions:
    sudo chown -R apache:apache /var/www/mediawiki
    sudo restorecon -FR /var/www/mediawiki/

These steps place the MediaWiki files in the appropriate web directory and ensure that the web server has the necessary permissions to access them.

2.4 Configuring Apache for MediaWiki

To make MediaWiki accessible via a web browser, we need to configure Apache:

  1. Create a virtual host configuration file for MediaWiki:
    sudo nano /etc/httpd/conf.d/mediawiki.conf
  2. Add the following configuration, replacing ‘yourdomain.com’ with your actual domain:
    <VirtualHost *:80>
        ServerName yourdomain.com
        DocumentRoot /var/www/mediawiki
    
        <Directory /var/www/mediawiki>
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
  3. Save the file and exit the editor.
  4. Restart Apache to apply the changes:
    sudo systemctl restart httpd

This configuration tells Apache how to serve your MediaWiki installation.

2.5 Running the Web-Based Installer

With the server configured, we can now run MediaWiki’s web-based installer:

  1. Open a web browser and navigate to http://yourdomain.com.
  2. You should see the MediaWiki installation page. Click “set up the wiki” to begin.
  3. Choose your preferred language and click “Continue”.
  4. The installer will check your environment. If all requirements are met, click “Continue”.
  5. On the “Connect to database” page, enter the following details:
    • Database type: MariaDB
    • Database host: localhost
    • Database name: mediawiki
    • Database username: wikiuser
    • Database password: (the password you set earlier)
  6. Click “Continue” and proceed through the next steps, setting up your wiki name, admin account, and other configurations as desired.
  7. On the final step, you’ll be prompted to download a file called LocalSettings.php. Save this file to your local computer.

The web-based installer guides you through the final configuration steps and generates the necessary settings file for your MediaWiki installation.

Install MediaWiki on Rocky Linux 9

2.6 Finalizing Installation

To complete the installation, we need to place the LocalSettings.php file in the correct location:

  1. Upload the LocalSettings.php file to your server:
    scp /path/to/LocalSettings.php user@yourdomain.com:/tmp/
  2. Move the file to the MediaWiki directory:
    sudo mv /tmp/LocalSettings.php /var/www/mediawiki/
    sudo chown apache:apache /var/www/mediawiki/LocalSettings.php
  3. Verify the installation by accessing your domain in a web browser. You should now see your fully functional MediaWiki site.

With these steps completed, you’ve successfully installed MediaWiki on your Rocky Linux 9 server!

3. Post-Installation Configuration

After successfully installing MediaWiki, there are several important configurations and optimizations you should consider to enhance security, performance, and functionality.

3.1 Enabling HTTPS with SSL

Securing your wiki with HTTPS is crucial for protecting user data and maintaining trust. Let’s set up SSL using Certbot:

  1. Install Certbot and its Apache plugin:
    sudo dnf install certbot python3-certbot-apache -y
  2. Obtain and install an SSL certificate:
    sudo certbot --apache -d yourdomain.com

    Follow the prompts to complete the process.

  3. Certbot will automatically configure Apache to use HTTPS. Ensure that your MediaWiki configuration in LocalSettings.php uses HTTPS URLs.

3.2 Performance Optimization

To improve MediaWiki’s performance, consider implementing the following optimizations:

  • Enable caching:
    sudo dnf install php-pecl-apcu
    sudo systemctl restart php-fpm

    Then, add the following to your LocalSettings.php:

    $wgMainCacheType = CACHE_ACCEL;
  • Optimize PHP settings in /etc/php.ini:
    • Increase memory_limit to at least 128M
    • Set max_execution_time to 60 or higher
    • Enable opcache for better PHP performance

3.3 Security Best Practices

Enhance the security of your MediaWiki installation with these practices:

  • Regularly update MediaWiki to the latest version to patch security vulnerabilities.
  • Use strong passwords for all accounts, especially the admin account.
  • Implement rate limiting to prevent brute-force attacks.
  • Consider using extensions like SpamBlacklist to prevent spam.
  • Regularly backup your wiki database and files.

4. Troubleshooting Common Issues

Even with careful installation, you might encounter some issues. Here are solutions to common problems:

Database Connection Errors

If you’re seeing database connection errors:

  1. Verify the database credentials in LocalSettings.php.
  2. Ensure the MariaDB service is running: sudo systemctl status mariadb
  3. Check if the database user has the correct permissions.

Permission Issues

For “Permission Denied” errors:

  1. Check file ownership: ls -l /var/www/mediawiki
  2. Ensure all files are owned by the Apache user: sudo chown -R apache:apache /var/www/mediawiki
  3. Set correct permissions: sudo chmod -R 755 /var/www/mediawiki

PHP Module Errors

If you’re missing PHP modules:

  1. Check installed PHP modules: php -m
  2. Install any missing required modules: sudo dnf install php-[module_name]
  3. Restart Apache after installing new modules: sudo systemctl restart httpd

Congratulations! You have successfully installed MediaWiki. Thanks for using this tutorial for installing the MediaWiki on your Rocky Linux 9 system. For additional help or useful information, we recommend you check the official MediaWiki website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button