Guides 11792 Published by

Installing MediaWiki on a fresh CentOS 8 machine involves updating the system, installing Apache, MariaDB, and PHP‑7.4 modules, then securing MariaDB with a strong root password and removing test data. After creating a dedicated database and user, the latest MediaWiki tarball is fetched from Wikimedia’s mirrors, extracted into /var/www/html, and file permissions are set so that the apache user can write cache and uploads without error. A virtual host configuration is added to give the wiki its own domain or subdomain, followed by restarting Apache, after which you run the web installer in a browser to create LocalSettings.php and populate the database tables. Finally, optional hardening steps like disabling display_errors, tightening firewall rules, and verifying access to the main page ensure the setup is both secure and functional.



Installing MediaWiki on CentOS 8 – Get Your Wiki Up and Running in Minutes

You’ll learn how to pull MediaWiki out of the tarball, hook it up to Apache, PHP 7.4, and MariaDB, then fix the permissions that usually trip people up.

Prerequisites: What You Need Before You Start
  • A fresh CentOS 8 box (root or sudo access).
  • Basic knowledge of SSH and the terminal.
  • A domain or IP pointing to your server if you plan to expose the wiki publicly.

If your machine is already serving other sites, just make sure Apache isn’t using port 80 for something else.

Step 1: Update the System and Install Core Packages
sudo dnf update -y
sudo dnf install httpd mariadb-server php php-mysqlnd php-xml php-gd php-intl php-json -y

Updating pulls in security fixes that keep your stack from being a walking dumpster. Installing the MariaDB and PHP modules ensures the wiki can talk to the database and render pages.

Step 2: Start and Secure MariaDB
sudo systemctl enable --now mariadb
sudo mysql_secure_installation

During mysql_secure_installation, set a strong root password, remove anonymous users, disallow remote root logins, and drop the test database. These are the same hardening steps you’d do on any production server.

Step 3: Create the Wiki Database and User
CREATE DATABASE mediawiki CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT ALL PRIVILEGES ON mediawiki.* TO 'mwuser'@'localhost' IDENTIFIED BY 'StrongPassword';
FLUSH PRIVILEGES;

Give the wiki its own database and user. Keep the password out of any public script, of course.

Step 4: Pull MediaWiki from GitHub
cd /var/www/html
sudo wget https://releases.wikimedia.org/mediawiki/1.41/mediawiki-1.41.0.tar.gz
sudo tar -xzf mediawiki-1.41.0.tar.gz --strip-components=1
sudo rm mediawiki-1.41.0.tar.gz

--strip-components=1 flattens the archive so you don’t end up with a nested directory. The wget command fetches the latest stable release straight from Wikimedia’s own mirrors.

Step 5: Set File Permissions Right
sudo chown -R apache:apache /var/www/html
sudo find /var/www/html -type d -exec chmod 755 {} \;
sudo find /var/www/html -type f -exec chmod 644 {} \;

If you skip this, the web server might scream “Permission denied” when trying to write cache or upload files. I’ve seen users hit a 500 error after moving /var/www/html to another owner – it’s that easy.

Step 6: Configure Apache for MediaWiki

Create a virtual host file:

sudo vi /etc/httpd/conf.d/mediawiki.conf

Add:

<VirtualHost *:80>
    ServerName wiki.example.com
    DocumentRoot /var/www/html

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

    ErrorLog  /var/log/httpd/mediawiki_error.log
    CustomLog /var/log/httpd/mediawiki_access.log combined
</VirtualHost>

Restart Apache:

sudo systemctl restart httpd

This gives MediaWiki its own domain (or subdomain) and logs. If you don’t set up a proper vhost, the default site may conflict with other apps.

Step 7: Run the Web Installer

Open a browser and navigate to http://wiki.example.com. The MediaWiki welcome page will ask for:

  • Database type: MySQL
  • Host: localhost
  • User & Password: mwuser / StrongPassword
  • Database name: mediawiki

Follow the on‑screen prompts. When you hit “Install,” the script writes LocalSettings.php and creates the necessary tables.

Step 8: Harden the Setup (Optional but Recommended)
  • Add AllowOverride None to your Apache config if you don’t need .htaccess.
  • Disable PHP’s display_errors in production.
  • Put a firewall rule blocking all ports except 80/443.
Step 9: Verify the Wiki is Working

Navigate to http://wiki.example.com/index.php/Main_Page. You should see the default “Welcome to MediaWiki” page. Try creating an account and editing a page; if you can do that without a 403 or 500 error, you’re golden.

That’s it. From a clean CentOS 8 install to a fully functional wiki in under twenty minutes.