LocalSettings.php Tweaks: Difference between revisions
No edit summary Tag: Manual revert |
mNo edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 14: | Line 14: | ||
* Run from the directory containing <code>LocalSettings.php</code>. | * Run from the directory containing <code>LocalSettings.php</code>. | ||
* To roll back: <code>mv LocalSettings.php.bak LocalSettings.php</code> | * To roll back: <code>mv LocalSettings.php.bak LocalSettings.php</code> | ||
---- | |||
=== Installed SyntaxHighlight extension === | |||
'''Why:''' Enables colored/highlighted code blocks (<code><nowiki><syntaxhighlight></nowiki></code>) on wiki pages instead of plain <code><nowiki><pre></nowiki></code> text. | |||
'''Commands:''' | |||
<syntaxhighlight lang="bash"> | |||
# 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 | |||
</syntaxhighlight> | |||
'''Notes:''' | |||
* No <code>pip install</code> needed — Pygments ships bundled with this extension version. | |||
* Verified working by testing a <code>bash</code> block on this page. | |||
---- | |||
=== Editing LocalSettings.php on this container (sed workaround) === | |||
'''Why:''' <code>LocalSettings.php</code> is a bind-mounted file (mounted in from the NAS host, not a normal file inside the container). Standard <code>sed -i</code> 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: | |||
<pre> | |||
sed: cannot rename /var/www/html/LocalSettings.php: Device or resource busy | |||
</pre> | |||
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):''' | |||
<syntaxhighlight lang="bash"> | |||
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 | |||
</syntaxhighlight> | |||
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):''' | |||
<syntaxhighlight lang="bash"> | |||
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 | |||
</syntaxhighlight> | |||
'''Verify the change landed:''' | |||
<syntaxhighlight lang="bash"> | |||
grep -i "SEARCH_TERM" /var/www/html/LocalSettings.php | |||
</syntaxhighlight> | |||
'''Notes:''' | |||
* Do '''not''' use <code>sed -i</code> or <code>sed -i.bak</code> on this file — it will fail with "Device or resource busy." | |||
* <code>$wgDefaultSkin</code> wants the '''lowercase internal key''' (e.g. <code>vector</code>, <code>minerva</code>, <code>monobook</code>) — not the mixed-case name used in <code>wfLoadSkin()</code> calls (e.g. <code>'Vector'</code>, <code>'MinervaNeue'</code>, <code>'MonoBook'</code>). Mixing these up causes MediaWiki to silently fall back to a different skin. | |||
* To see all skins currently loaded and available: <code>grep -i wfLoadSkin /var/www/html/LocalSettings.php</code> | |||
* Access this file via: SSH into the NAS → <code>sudo docker exec -it <container_name> bash</code> → file lives at <code>/var/www/html/LocalSettings.php</code> | |||
---- | ---- | ||
| Line 38: | Line 94: | ||
---- | ---- | ||
</pre> | </pre> | ||
[[Category:MediaWiki Administration]] | |||
[[Category:How-To]] | |||
''Last updated: [[User:Kmilleca|Kmilleca]] ([[User talk:Kmilleca|talk]]) 12:43, 3 August 2026 (UTC)'' | ''Last updated: [[User:Kmilleca|Kmilleca]] ([[User talk:Kmilleca|talk]]) 12:43, 3 August 2026 (UTC)'' | ||
Latest revision as of 20:39, 14 August 2026
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.bakbefore 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 installneeded — Pygments ships bundled with this extension version. - Verified working by testing a
bashblock 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 -iorsed -i.bakon this file — it will fail with "Device or resource busy." $wgDefaultSkinwants the lowercase internal key (e.g.vector,minerva,monobook) — not the mixed-case name used inwfLoadSkin()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] ----