Jump to content

ICT:MW Installation procedure 1.43 LTS: Difference between revisions

From Costa Sano MediaWiki
No edit summary
No edit summary
Line 1: Line 1:
= Installation Procedure for newMW (MediaWiki 1.43 LTS) =
= Installation Procedure for newMW (MediaWiki 1.43 LTS) =
This document describes the clean, reproducible installation workflow for
This document describes the clean, reproducible installation workflow for
deploying a new MediaWiki instance (newMW) on the existing 3‑VM infrastructure.
deploying a new MediaWiki instance (newMW) on the existing 3‑VM infrastructure.
It includes directory preparation, file extraction, permissions, database
The installation is intentionally split into two phases:
creation, and the preferred ownership model for VS Code access.
 
* Phase 1: Local installation and testing on VM1 (no reverse‑proxy required)
* Phase 2: Public exposure through VM3 (nginx reverse‑proxy)
 
This staged approach allows safe testing before the wiki becomes accessible
from the internet.


== 1. Create the newwiki Database (VM2 – Database Layer) ==
== 1. Create the newwiki Database (VM2 – Database Layer) ==
Line 124: Line 130:
</pre>
</pre>


== 7. Apache Virtual Host (VM1) ==
== 7. Local‑Only Apache Virtual Host (VM1) ==
Create a vhost:
This vhost allows installation and testing without involving the reverse‑proxy.


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


Line 137: Line 143:
     </Directory>
     </Directory>


     ErrorLog /var/log/httpd/newwiki-error.log
     ErrorLog /var/log/httpd/newmw-local-error.log
     CustomLog /var/log/httpd/newwiki-access.log combined
     CustomLog /var/log/httpd/newmw-local-access.log combined
</VirtualHost>
</VirtualHost>
</pre>
</pre>
Line 148: Line 154:
</pre>
</pre>


== 8. nginx Reverse‑Proxy (VM3) ==
== 8. Run the Installer Locally ==
Add a server block:
Access the installer using one of:
 
* <code>http://VM1-IP:8080</code>
* <code>http://newmw.local:8080</code> (if added to /etc/hosts)
 
Complete the installation.
 
The installer will generate a <code>LocalSettings.php</code> with:
 
<pre>
$wgServer = "http://VM1-IP:8080";
</pre>
 
Place the file in:
 
<pre>
/var/www/newMW/LocalSettings.php
</pre>
 
== 9. Local Testing ==
Before exposing the wiki publicly, verify:
 
* Page creation
* Editing
* File uploads (if enabled)
* User accounts
* Extensions
* Permissions
* Logging
 
This phase is isolated and safe.
 
== 10. Prepare for Public Access (VM3 – Reverse‑Proxy Layer) ==
Only after local testing is complete, add the nginx server block:


<pre>
<pre>
Line 170: Line 209:
</pre>
</pre>


== 9. Run the MediaWiki Installer ==
== 11. Update LocalSettings.php for Public Access ==
Navigate to:
Change:
 
<pre>
https://newwiki.example.com
</pre>
 
Provide:
* Database: <code>newwiki</code>
* User: <code>newwikiuser</code>
* Password: (as created on VM2)
* Site name
* Admin account
 
Download <code>LocalSettings.php</code> and place it in:
 
<pre>
/var/www/newMW/LocalSettings.php
</pre>
 
== 10. Minimal Post‑Install Configuration ==
Add or verify:


<pre>
<pre>
$wgServer = "https://newwiki.example.com";
$wgServer = "https://newwiki.example.com";
$wgScriptPath = "";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;
</pre>
Enable uploads (optional):
<pre>
$wgEnableUploads = true;
</pre>
</pre>


Enable SyntaxHighlight:
Optionally:


<pre>
<pre>
wfLoadExtension( 'SyntaxHighlight_GeSHi' );
$wgCanonicalServer = "https://newwiki.example.com";
</pre>
</pre>


== 11. Verification Checklist ==
== 12. Final Verification ==
* Site loads correctly
* Public URL loads correctly
* <code>/wiki/Main_Page</code> resolves
* <code>/wiki/Main_Page</code> resolves
* Editing works
* Editing works
* File uploads work (if enabled)
* Uploads work
* No rewrite errors in Apache logs
* No rewrite errors in Apache logs
* nginx proxies correctly
* nginx proxies correctly
* MariaDB connections succeed
* MariaDB connections succeed


== 12. Summary ==
== 13. Summary ==
This procedure provides a clean, repeatable installation workflow for MediaWiki
This procedure installs MediaWiki in two safe phases:
1.43 LTS using the preferred ownership model (<code>mngr:apache</code>) and the
 
existing 3‑VM architecture. It ensures clarity, maintainability, and
* Phase 1: Local installation and validation on VM1
successor‑friendly operation.
* Phase 2: Public exposure through VM3
 
This staged approach avoids dependency on the reverse‑proxy during installation
and allows controlled, low‑risk rollout.

Revision as of 13:36, 3 April 2026

Installation Procedure for newMW (MediaWiki 1.43 LTS)

This document describes the clean, reproducible installation workflow for deploying a new MediaWiki instance (newMW) on the existing 3‑VM infrastructure. The installation is intentionally split into two phases:

  • Phase 1: Local installation and testing on VM1 (no reverse‑proxy required)
  • Phase 2: Public exposure through VM3 (nginx reverse‑proxy)

This staged approach allows safe testing before the wiki becomes accessible from the internet.

1. Create the newwiki Database (VM2 – Database Layer)

All commands in this section are executed on VM2.

1.1 Connect to MariaDB

mysql -u root -p

1.2 Create the database

CREATE DATABASE newwiki
  CHARACTER SET utf8mb4
  COLLATE utf8mb4_unicode_ci;

1.3 Create the database user

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

CREATE USER 'newwikiuser'@'VM1-IP' IDENTIFIED BY 'strongpassword';

1.4 Grant privileges

GRANT ALL PRIVILEGES ON newwiki.* TO 'newwikiuser'@'VM1-IP';
FLUSH PRIVILEGES;

1.5 Exit MariaDB

EXIT;

2. Prepare the Installation Directory (VM1 – Web Layer)

All commands below are executed on VM1.

2.1 Create the target directory

mkdir /var/www/newMW

2.2 Move into the working directory

cd /var/www

3. Download MediaWiki

Download the latest LTS tarball (example: 1.43.8):

wget https://releases.wikimedia.org/mediawiki/1.43/mediawiki-1.43.8.tar.gz

4. Extract MediaWiki

Extract the archive. This creates a directory such as mediawiki-1.43.8/.

tar -xvzf mediawiki-1.43.8.tar.gz

5. Move Extracted Files into newMW

Move normal files:

mv mediawiki-1.43.8/* newMW/

Move hidden files (e.g. .htaccess):

mv mediawiki-1.43.8/.* newMW/ 2>/dev/null

Remove the now‑empty extraction directory:

rmdir mediawiki-1.43.8

Remove the tarball:

rm mediawiki-1.43.8.tar.gz

6. Ownership and Permissions

Use the preferred ownership model to allow editing via VS Code while keeping Apache fully functional.

6.1 Set owner and group

chown -R mngr:apache /var/www/newMW

6.2 Ensure group write permissions

chmod -R g+w /var/www/newMW

6.3 Apply clean directory/file permissions

Directories:

find /var/www/newMW -type d -exec chmod 775 {} \;

Files:

find /var/www/newMW -type f -exec chmod 664 {} \;

6.4 Enable group inheritance (setgid)

Ensures new files created inside inherit the apache group.

chmod g+s /var/www/newMW

7. Local‑Only Apache Virtual Host (VM1)

This vhost allows installation and testing without involving the reverse‑proxy.

<VirtualHost *:8080>
    ServerName newmw.local
    DocumentRoot /var/www/newMW

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

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

Restart Apache:

systemctl restart httpd

8. Run the Installer Locally

Access the installer using one of:

Complete the installation.

The installer will generate a LocalSettings.php with:

$wgServer = "http://VM1-IP:8080";

Place the file in:

/var/www/newMW/LocalSettings.php

9. Local Testing

Before exposing the wiki publicly, verify:

  • Page creation
  • Editing
  • File uploads (if enabled)
  • User accounts
  • Extensions
  • Permissions
  • Logging

This phase is isolated and safe.

10. Prepare for Public Access (VM3 – Reverse‑Proxy Layer)

Only after local testing is complete, add the nginx server block:

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

11. Update LocalSettings.php for Public Access

Change:

$wgServer = "https://newwiki.example.com";

Optionally:

$wgCanonicalServer = "https://newwiki.example.com";

12. Final Verification

  • Public URL loads correctly
  • /wiki/Main_Page resolves
  • Editing works
  • Uploads work
  • No rewrite errors in Apache logs
  • nginx proxies correctly
  • MariaDB connections succeed

13. Summary

This procedure installs MediaWiki in two safe phases:

  • Phase 1: Local installation and validation on VM1
  • Phase 2: Public exposure through VM3

This staged approach avoids dependency on the reverse‑proxy during installation and allows controlled, low‑risk rollout.