LocalSettings.php Tweaks

From MemoryLeak
Revision as of 20:15, 4 August 2026 by Kmilleca (talk | contribs)
Jump to navigation Jump to search

A running log of manual edits made to LocalSettings.php, why they were made, and how to reverse them if needed.

Skin: MinervaNeue → minerva

Why: $wgDefaultSkin expects the internal skin key, not its display name. The mobile skin is labeled "MinervaNeue" in the UI, but its actual key is minerva. Setting the display name instead of the key causes MediaWiki to silently fall back to the default skin.

Command:

sed -i.bak 's/\$wgDefaultSkin = "MinervaNeue";/\$wgDefaultSkin = "minerva";/' LocalSettings.php

Notes:

  • Creates a backup at LocalSettings.php.bak before editing in place.
  • Run from the directory containing LocalSettings.php.
  • To roll back: mv LocalSettings.php.bak LocalSettings.php

Installed SyntaxHighlight extension

Why: Enables colored/highlighted code blocks (<syntaxhighlight>) on wiki pages instead of plain <pre> text.

Commands:

# Extension was already bundled in the container image at:
# /var/www/html/extensions/SyntaxHighlight_GeSHi
# (Pygments 2.19.2 bundled at extensions/SyntaxHighlight_GeSHi/pygments)

echo 'wfLoadExtension( "SyntaxHighlight_GeSHi" );' >> /var/www/html/LocalSettings.php

Notes:

  • No pip install needed — Pygments ships bundled with this extension version.
  • Verified working by testing a bash block on this page.

Editing LocalSettings.php on this container (sed workaround)

Why: LocalSettings.php is a bind-mounted file (mounted in from the NAS host, not a normal file inside the container). Standard sed -i works by writing a temp file and then renaming it over the original — but bind-mounted files can't be renamed this way while in use, so it fails with:

sed: cannot rename /var/www/html/LocalSettings.php: Device or resource busy

No changes are lost when this happens — it just means the edit didn't go through, and you need a different method.

Command (safe method — no rename involved):

sed 's/OLD_VALUE/NEW_VALUE/' /var/www/html/LocalSettings.php > /tmp/LocalSettings.php.tmp
cat /tmp/LocalSettings.php.tmp > /var/www/html/LocalSettings.php
rm /tmp/LocalSettings.php.tmp

This writes the modified content into the existing file instead of replacing it, which works fine on bind mounts.

Example (skin change from MonoBook to Vector):

sed 's/\$wgDefaultSkin = "MonoBook";/\$wgDefaultSkin = "vector";/' /var/www/html/LocalSettings.php > /tmp/LocalSettings.php.tmp
cat /tmp/LocalSettings.php.tmp > /var/www/html/LocalSettings.php
rm /tmp/LocalSettings.php.tmp

Verify the change landed:

grep -i "SEARCH_TERM" /var/www/html/LocalSettings.php

Notes:

  • Do not use sed -i or sed -i.bak on this file — it will fail with "Device or resource busy."
  • $wgDefaultSkin wants the lowercase internal key (e.g. vector, minerva, monobook) — not the mixed-case name used in wfLoadSkin() calls (e.g. 'Vector', 'MinervaNeue', 'MonoBook'). Mixing these up causes MediaWiki to silently fall back to a different skin.
  • To see all skins currently loaded and available: grep -i wfLoadSkin /var/www/html/LocalSettings.php
  • Access this file via: SSH into the NAS → sudo docker exec -it <container_name> bash → file lives at /var/www/html/LocalSettings.php

Template for Future Entries

Copy this block below the last entry and fill it in for each new tweak.

=== [Short description of the change] ===

'''Why:''' [What problem this solves or what behavior it changes, and any gotchas worth remembering.]

'''Command:'''
<syntaxhighlight lang="bash">
[the command here]
</syntaxhighlight>

'''Notes:'''
* [Backup/rollback info]
* [Any prerequisites, e.g. run from X directory]
* [Anything else future-you would want to know]

----

Last updated: Kmilleca (talk) 12:43, 3 August 2026 (UTC)