How to Install MediaWiki on AlmaLinux 9

This step-by-step guide from EcoStack Cloud explains how to install and configure MediaWiki on AlmaLinux 9. Follow these instructions to set up your own wiki platform, perfect for collaborative documentation and knowledge sharing on our NVMe VPS.

almalinux mediawiki
Nano
VPS
1
vCPU
1 GB
Memory
10 GB
NVMe Disk
512 GB
Traffic
2.90
/month
* Up to 3GB RAM, 30GB NVMe Disk Space and 1Gbit/s Network Speed
#### Prerequisites Before starting the installation, ensure you have: - A KVM-based NVMe VPS from [EcoStack Cloud](https://ecostack.cloud) running AlmaLinux 9. - A user account with sudo privileges. - A registered domain name pointing to your server (optional but recommended). #### Step 1: Update the System First, update your system packages to the latest versions. ```bash sudo dnf update -y ``` #### Step 2: Install LAMP Stack MediaWiki requires a web server, a database server, and PHP. We'll set up the LAMP stack (Linux, Apache, MariaDB, PHP). ##### Install Apache Install Apache HTTP Server and start it. ```bash sudo dnf install httpd -y sudo systemctl start httpd sudo systemctl enable httpd ``` ##### Install MariaDB Install MariaDB server and start it. ```bash sudo dnf install mariadb-server -y sudo systemctl start mariadb sudo systemctl enable mariadb ``` Secure MariaDB installation by running the security script: ```bash sudo mysql_secure_installation ``` Follow the prompts to set the root password and secure your MariaDB installation. ##### Install PHP and Extensions Install PHP and the necessary PHP extensions for MediaWiki. ```bash sudo dnf install php php-mysqlnd php-xml php-mbstring php-intl php-gd php-json php-zip -y ``` Restart Apache to load PHP: ```bash sudo systemctl restart httpd ``` #### Step 3: Create a Database for MediaWiki Log in to MariaDB and create a database and user for MediaWiki. ```bash sudo mysql -u root -p ``` In the MariaDB shell, run the following commands: ```sql CREATE DATABASE mediawiki; CREATE USER 'wikiuser'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL PRIVILEGES ON mediawiki.* TO 'wikiuser'@'localhost'; FLUSH PRIVILEGES; EXIT; ``` Replace `your_password` with a strong password of your choice. #### Step 4: Download and Extract MediaWiki Download the latest version of MediaWiki from the official website. ```bash cd /var/www/html sudo wget https://releases.wikimedia.org/mediawiki/1.39/mediawiki-1.39.4.tar.gz ``` Extract the downloaded file and move it to the desired directory. ```bash sudo tar -xvzf mediawiki-*.tar.gz sudo mv mediawiki-1.39.4 mediawiki ``` Set the appropriate permissions: ```bash sudo chown -R apache:apache /var/www/html/mediawiki sudo chmod -R 755 /var/www/html/mediawiki ``` #### Step 5: Configure Apache for MediaWiki Create a new Apache configuration file for MediaWiki. ```bash sudo nano /etc/httpd/conf.d/mediawiki.conf ``` Add the following configuration: ```apache ServerAdmin admin@your_domain DocumentRoot /var/www/html/mediawiki ServerName your_domain ServerAlias www.your_domain Options FollowSymLinks AllowOverride All Require all granted ErrorLog /var/log/httpd/mediawiki-error_log CustomLog /var/log/httpd/mediawiki-access_log combined ``` Replace `your_domain` with your actual domain name. Save and close the file. Test the Apache configuration for syntax errors: ```bash sudo httpd -t ``` Reload Apache to apply the changes: ```bash sudo systemctl reload httpd ``` #### Step 6: Complete the Installation via Web Browser Open your web browser and navigate to `http://your_domain` or `http://your_server_ip/mediawiki`. You will see the MediaWiki setup page. Follow these steps to complete the installation: 1. **Choose Your Language**: Select your preferred language. 2. **Connect to Database**: Enter the database details you created earlier: - Database type: MySQL - Database host: localhost - Database name: mediawiki - Database username: wikiuser - Database password: The password you set 3. **Configure the Wiki**: Provide a name for your wiki and create an admin account. 4. **Finalize**: Follow the prompts to complete the setup. MediaWiki will generate a `LocalSettings.php` file. 5. **Save Configuration**: Download the `LocalSettings.php` file and upload it to the root of your MediaWiki installation directory (`/var/www/html/mediawiki/`). You can upload the file using SCP or any preferred file transfer method. #### Conclusion You have successfully installed and configured MediaWiki on AlmaLinux 9 using [EcoStack Cloud](https://ecostack.cloud). Your wiki platform is now ready for use, providing a powerful tool for collaborative documentation and knowledge management. For more detailed configurations and advanced features, refer to the [official MediaWiki documentation](https://www.mediawiki.org/wiki/Manual:Installation_guide).


Created with ❤ at Estonia
EcoStack Technology OÜ