Modifying and Uploading Wiki Configuration Files - dteck/Mediawiki-GCP-CR GitHub Wiki

Getting Started

The reason we want to make some manual edits to our LocalSettings.php file is so that we can tell our Wiki to read certain values from our environmental variables instead of having them hard coded into this file. This will make it much easier to make updates or migrate later if needed. It also makes sure that if this file were to be compromised that nothing sensitive exists inside of it.

Editing LocalSettings.php

This file can be opened with the text editor of your choice. I personally prefer Notepad++ as it allows me to do syntax highlighting, but the built in windows notepad will work just as well.

We are looking for some very specific settings we want to update. This list below shows the settings as well as the syntax and values we want to set them to. PHP is able to read environmental variables with the getenv('[ENV Name]'); syntax.

$wgServer = getenv('FQDN');
$wgLogos = [ '1x' => "$wgResourceBasePath/wiki.png" ];
$wgDBserver = getenv('DBHOST');
$wgDBname = getenv('DBNAME');
$wgDBuser = getenv('DBUSER');
$wgDBpassword = getenv('DBPASS');
$wgRateLimits = [
        // Page edits
        'edit' => [
                'ip' => [ 9000, 60 ],
                'newbie' => [ 9000, 60 ],
                'user' => [ 9000, 60 ],
        ]];
$wgDBprefix = getenv('DBPREFIX');

The $wgRateLimits code will likely not be included in the default LocalSettings.php file that was created. This code block changes the number of pages that can be edited per minute by a user. In my use case I plan on running scripts to automate administrative tasks and will want those scripts to be able to make hundreds of updates without having to wait on a cooldown timer.

I recommend searching the file for the setting name and then copy and pasting the values from above in place of whatever is there currently.

Uploading LocalSettings.php to your Configuration Bucket

Navigate back to your Cloud Storage and find your configuration bucket. From here you will want to use the Upload Files function Upload your modified copy of the LocalSetting.php Note that the name must be the same. You can also upload any image you want to use as your logo. This must be 135x135 pixels and named wiki.png.

Next Steps

Updating Cloud Run Variables