Jump to content

ICT:PL Adding new MediaWiki website

From Costa Sano MediaWiki
Revision as of 11:14, 3 April 2026 by Mngr (talk | contribs) (Created page with "= Infrastructure Overview and Procedure for Adding a New MediaWiki Instance = This document describes the current three‑VM infrastructure used for hosting Drupal, MediaWiki, and related services. It also explains how to add a new MediaWiki instance (newMW) to the existing environment in a clean, reproducible, and low‑risk manner. == 1. High-Level Architecture == The system is composed of three virtual machines running on Hyper‑V. Each VM has a clearly defined resp...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Infrastructure Overview and Procedure for Adding a New MediaWiki Instance

This document describes the current three‑VM infrastructure used for hosting Drupal, MediaWiki, and related services. It also explains how to add a new MediaWiki instance (newMW) to the existing environment in a clean, reproducible, and low‑risk manner.

1. High-Level Architecture

The system is composed of three virtual machines running on Hyper‑V. Each VM has a clearly defined responsibility, forming a layered, production‑grade architecture.

1.1 VM1 – Web Layer (AlmaLinux)

  • Runs Apache (httpd)
  • Runs PHP
  • Hosts:
    • Drupal website
    • oldMW (existing MediaWiki instance)
    • newMW (to be added)
  • Contains all Apache vhosts
  • Contains all rewrite rules (important: rewrites are NOT in nginx)
  • Receives traffic only from VM3 (reverse‑proxy)

1.2 VM2 – Database Layer (AlmaLinux)

  • Runs MariaDB
  • Hosts multiple independent databases:
    • drupal
    • oldwiki
    • newwiki (to be created)
  • Accessible only from VM1 (internal Hyper‑V network)

1.3 VM3 – Reverse‑Proxy Layer (AlmaLinux)

  • Runs nginx
  • Public-facing entry point
  • Terminates HTTPS
  • Routes incoming requests to VM1 based on domain name
  • Does NOT perform URL rewriting
  • Forwards Host header and client IP

2. Traffic Flow

  1. Client connects to VM3 (nginx) using HTTPS.
  2. nginx selects the correct server block based on the domain.
  3. nginx forwards the request to VM1 (Apache) using proxy_pass.
  4. Apache selects the correct vhost based on ServerName.
  5. Apache applies rewrite rules and serves the application.
  6. Application (Drupal or MediaWiki) connects to VM2 (MariaDB) as needed.

This separation ensures stability, clarity, and easy maintenance.

3. Why This Architecture Works Well

  • Each VM has a single responsibility.
  • nginx handles routing and SSL termination.
  • Apache handles application logic and rewrites.
  • MariaDB is isolated and easy to back up.
  • Adding new sites is predictable and low-risk.
  • No component needs to be modified outside its domain.

4. Adding a New MediaWiki Instance (newMW)

Adding newMW requires changes on all three VMs, but each change is small, isolated, and predictable.

4.1 Step 1 – Create the Database on VM2 (MariaDB)

Connect to MariaDB and create a new database and user:

CREATE DATABASE newwiki CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'newwikiuser'@'VM1-IP' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON newwiki.* TO 'newwikiuser'@'VM1-IP';
FLUSH PRIVILEGES;

Replace VM1-IP with the internal Hyper‑V IP of the web server.

4.2 Step 2 – Install MediaWiki on VM1 (Web Layer)

Download and extract MediaWiki 1.43 LTS:

cd /var/www
wget https://releases.wikimedia.org/mediawiki/1.43/mediawiki-1.43.0.tar.gz
tar -xvzf mediawiki-1.43.0.tar.gz
mv mediawiki-1.43.0 newMW
chown -R apache:apache /var/www/newMW

4.3 Step 3 – Create an Apache vhost on VM1

Create a new vhost file:

<VirtualHost *:8080>
    ServerName newwiki.example.com
    DocumentRoot /var/www/newMW

    <Directory /var/www/newMW>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog /var/log/httpd/newwiki-error.log
    CustomLog /var/log/httpd/newwiki-access.log combined
</VirtualHost>

Restart Apache:

systemctl restart httpd

4.4 Step 4 – Add a Reverse‑Proxy Entry on VM3 (nginx)

Duplicate an existing server block and adjust only the domain and proxy target:

server {
    listen 80;
    server_name newwiki.example.com;

    location / {
        proxy_pass http://VM1-IP:8080;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

Reload nginx:

systemctl reload nginx

4.5 Step 5 – Run the MediaWiki Installer

Navigate to:

https://newwiki.example.com

Provide:

  • Database: newwiki
  • User: newwikiuser
  • Password: (as created)
  • Site name
  • Admin account

Download LocalSettings.php and place it in:

/var/www/newMW/LocalSettings.php

4.6 Step 6 – Minimal Configuration in LocalSettings.php

Add or verify:

$wgServer = "https://newwiki.example.com";
$wgScriptPath = "";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;

Enable uploads if needed:

$wgEnableUploads = true;

Install SyntaxHighlight:

wfLoadExtension( 'SyntaxHighlight_GeSHi' );

5. Verification Checklist

  • https://newwiki.example.com loads correctly.
  • /wiki/Main_Page resolves without errors.
  • Editing works.
  • File uploads work (if enabled).
  • No rewrite errors in Apache logs.
  • nginx logs show correct proxying.
  • MariaDB logs show successful connections from VM1.

6. Summary

Adding a new MediaWiki instance is straightforward because:

  • nginx handles only routing.
  • Apache handles rewrites and vhosts.
  • MariaDB handles isolated databases.
  • Each VM has a clear, stable role.
  • The existing configuration already supports multi‑site operation.

This document provides a reproducible procedure for extending the system without reintroducing the complexity or debugging effort experienced during the initial setup.