Self Hosted MediaWiki

Hi @LTS_Tom

Can you please tell me if your are still maintaining the Self Hosted Media Wiki Debian VM from

Il like to try it but wonder how much updating I’ll need to do.

Thank you

I have not had the time to make a new VM. I have not tested it but there is a docker version https://hub.docker.com/_/mediawiki

Hi Tom, thank you for the link.

You only need to search for upgrade guides from one version to the next, very few out there, because it’s a real pain. The irony with Mediawiki is their documentation on how to update, upgrade add extensions is really painful.

Installing it the first time is relatively easy in a vm, I’ve not tried the docker version maybe it’s easier to update/upgrade but now I have all my notes in a mediawiki vm.

Been working on this over the weekend, specifically with the MediaWiki (theWiki) VM Tom provided in 2018. This guide will be a multi part post as there seems to be a 2 link limit per post

That VM is a Debian 9 server with a MediaWiki v1.30 PHP 7.0.x and has parsoid installed to use the VisualEditor extension.
The current version of MediaWiki is 1.35.1 and VisualEditor is included in the “base” install
PHP 7.0 is no longer supported
PHP 7.3.x is supported and is the recommended version for MW 1.35.x

Below is how I was able to upgrade the MW VM from Tom. The upgrade requires
Upgrade PHP from 7.0. to 7.3
Upgrade MediaWiki from 1.30 to 1.35.1
Modify the LocalSettings.php configuration file
**** NOTE: The VM provided by Tom uses the root account so SUDO is not used for commands. If use a limited account, you will need to add sudo to each ot the commands below

First things - prep
Make a snapshot so you can roll things back if a mistake is made
if you have data in the MW server, suggest doing a backup of the DB
Update the OS and related packages
apt update && apt upgrade -yy && apt autoremove -y
NOTE: an error will appear when the update tries to pull from MediWiki update repos
the error can be ignored or removed with nano or vi (VIM)

1 Like

Upgrading PHP from 7.0 to 7.3

Stop the apache2 web server

systemctl stop apache2

(optional) see the currently installed version of PHP

php -v

(optional) get a list of the additional installed PHP modules

dpkg -l | grep php | tee packages.txt

(optional) See the list of installed PHP modules

nano packages.txt

Install the GNUGPG keys; next command installs 3 packages for maximum compatibility and reduces errors, also helps with updating other packages like Webmin

apt install gnupg gnupg1 gnupg2

Install the the gpg keyring for PHP 7.3

wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

add the PHP 7.3 packages to the repo for future updates

echo “deb Index of /php/ $(lsb_release -sc) main” | tee /etc/apt/sources.list.d/php7.3.list

update\refresh the available packages before install

apt update

Install PHP 7.3 and the CLI support tools

apt install php7.3 php7.3-common php7.3-cli

Pin PHP v 7.3 in the updates to prevent future updates from installing later versions, breaking things

update-alternatives --set php $(which php7.3)

Install the additional packages used by MediaWiki ( the command below is all one item)

apt install -y php7.3 libapache2-mod-php7.3 php7.3-bz2 php7.3-curl php7.3-gd php7.3-mbstring php7.3-mcrypt php7.3-mysql php7.3-xml php7.3-zip php7.3-curl php7.3-json php7.3-opcache php7.3-readline php7.3-xml php7.3-apc php7.3-imagick php7.3-int php7.3-fpm

Next two items were apache2 configuration changes after being prompted by the system after testing ( need to investigate but enable for now)

a2enconf php7.3-fpm
2enmod proxy_fcgi setenvif

(optional) see the installed version of PHP, should be 7.3.x

php -v

Uninstall and remove PHP 7.0 and related 7.0 items

apt purge php7.0 php7.0-common

Update the system one last time to make sure everything is the latest versions

apt update && apt upgrade -yy && apt autoremove -y

This should complete the PHP upgrade; a reboot is NOT required

The next step is the upgrade of the the MediWiki from 1.30 to 1.35.1

If the PHP upgrade went well, suggest taking another snapshot now

1 Like

############ Upgrading MediaWiki from 1.30 to 1.35.1 ##################

Process: Will create a sub directory near the place where the current MW install is at.

In that new subdir we will download the the MediaWiki 1.35.1 tarball, then run a command to install the new version into the area where the current install of 1.30 is when the extract is completed, it is necessary to run the update.php utility to take care of the PHP configuration adjustments

(optional) if you rebooted the system or restarted apache2, disable it now

systemctl stop apache2

make sure we are starting in the home dir

cd ~

create a new dir called MW near the current MediaWiki install. This new dir will be the working directory for downloading the new version of MediWiki 1.35.1

mkdir /var/www/mw

go into the new MW working dir

cd /var/www/mw

Backup the current MediaWiki LocalSettings.php file

This file is critical and contains all the configuration info for your MW install

cp /var/www/html/LocalSettings.php /var/www/html/LocalSettings.php.old.bak

download the new MediaWiki tarball

wget https://releases.wikimedia.org/mediawiki/1.35/mediawiki-1.35.1.tar.gz

(optional) can do a snapshot now as the next steps will install and overwrite the MW 1.30

Extract and install the new version of MediaWiki into the current working directory

tar xvzf mediawiki-1.35.1.tar.gz -C /var/www/html/ --strip-components=1

The extract and install should complete quickly

At this point MediaWiki 1.35.1 is installed. You can start apache2 and try to log in but the landing page will give an error and say the MW 1.35.1 is not configured

We need to complete the install with the update.php utility

/var/www/html/maintenance/update.php

The install should be completed and if you start apache2 (OPTIONAL) you can log into the MW. If you navigate to the special pages and version, it should say 1.35.1, however the VisualEditor and Editor are broken

Editing LocalSettings.php

(optional) Stop apache2 and we need to edit the LocalSettings.php

systemctl stop apache2

using nano we can edit the LocalSettings.php file, adjusting the configuration to use the new extensions. It seems that for upgrading existing installations of the MW with the VisualEditor extension, the upgrade reuses (or keeps) the existing install and configuration of VisualEditor

Have done new clean builds of MediaWiki with 1.35.x and there is no need to install and configure parsoid as it is built into the 1.35. Proof of this is the contents of the LocalSettings.php file after the first time run and initial MW configuration wizard.The LocalSetting.php file does not contain the sections related to $wgVirtualRestConfig

editing LocalSettings.php

nano /var/www/html/LocalSettings.php

Inside this file we need to comment out sections and add items. All of the work is done towards the bottom of the file as the Extensions are enabled and configured here

Comment out the old Extensions first by adding // each of the entries. It should look like this when completed. Added // OLD Options over this section for reference

// OLD Options
//wfLoadExtension( ‘Cite’ );
//wfLoadExtension( ‘CiteThisPage’ );
//wfLoadExtension( ‘Gadgets’ );
//wfLoadExtension( ‘ImageMap’ );
//wfLoadExtension( ‘InputBox’ );
//wfLoadExtension( ‘ParserFunctions’ );
//wfLoadExtension( ‘Poem’ );
//wfLoadExtension( ‘Renameuser’ );
//wfLoadExtension( ‘SyntaxHighlight_GeSHi’ );
//wfLoadExtension( ‘MsUpload’ );
//require_once “$IP/extensions/Vector/Vector.php”;
//wfLoadExtension( ‘WikiEditor’ );
//wfLoadExtension( ‘OATHAuth’ );
//wfLoadExtension( ‘UserPageViewTracker’ );

//wfLoadExtension( ‘VisualEditor’ );

##############################################################################

Next adding the new extensions to the file. Some of these may be options you find later you do not want or need. They can be disabled by adding // before the extension name. For continuity, I added these where the old ones started under and sent the old ones, commented out earlier, below the new ones

##############################################################################

wfLoadExtension( ‘CategoryTree’ );
wfLoadExtension( ‘Cite’ );
wfLoadExtension( ‘CiteThisPage’ );
wfLoadExtension( ‘ConfirmEdit’ );
wfLoadExtension( ‘Gadgets’ );
wfLoadExtension( ‘ImageMap’ );
wfLoadExtension( ‘InputBox’ );
wfLoadExtension( ‘Interwiki’ );
wfLoadExtension( ‘LocalisationUpdate’ );
wfLoadExtension( ‘MultimediaViewer’ );
wfLoadExtension( ‘Nuke’ );
wfLoadExtension( ‘OATHAuth’ );
wfLoadExtension( ‘PageImages’ );
wfLoadExtension( ‘ParserFunctions’ );
wfLoadExtension( ‘PdfHandler’ );
wfLoadExtension( ‘Poem’ );
wfLoadExtension( ‘Renameuser’ );
wfLoadExtension( ‘ReplaceText’ );
wfLoadExtension( ‘Scribunto’ );
wfLoadExtension( ‘SecureLinkFixer’ );
wfLoadExtension( ‘SpamBlacklist’ );
wfLoadExtension( ‘SyntaxHighlight_GeSHi’ );
wfLoadExtension( ‘TemplateData’ );
wfLoadExtension( ‘TextExtracts’ );
wfLoadExtension( ‘TitleBlacklist’ );
wfLoadExtension( ‘VisualEditor’ );
wfLoadExtension( ‘WikiEditor’ );

The end of the file contains the configuration for parsoid and the VisualEditor. My working example looks like this

// Enable by default for everybody
$wgDefaultUserOptions[‘visualeditor-enable’] = 1;
//
// // Optional: Set VisualEditor as the default for anonymous users
// // otherwise they will have to switch to VE
$wgDefaultUserOptions[‘visualeditor-editor’] = “visualeditor”;#
//
// // Don’t allow users to disable it
$wgHiddenPrefs[] = ‘visualeditor-enable’;
//
// // OPTIONAL: Enable VisualEditor’s experimental code features
$wgDefaultUserOptions[‘visualeditor-enable-experimental’] = 1;
//

$wgVisualEditorEnableWikitext = true;
$wgDefaultUserOptions[‘visualeditor-newwikitext’] = 1;
$wgHiddenPrefs[] = ‘visualeditor-newwikitext’;

$wgDisableUploadScriptChecks = true;

$wgVirtualRestConfig[‘modules’][‘parsoid’] = array(
// URL to the Parsoid instance
// Use port 8142 if you use the Debian package
‘url’ => ‘http://localhost:8142’,
// Parsoid “domain”, see below (optional)
‘domain’ => ‘localhost’,
// Parsoid “prefix”, see below (optional)
‘prefix’ => ‘localhost’
);

$wgVirtualRestConfig[‘modules’][‘parsoid’][‘forwardCookies’] = true;

// End of Old Options

$wgFileExtensions = array( ‘png’, ‘gif’, ‘jpg’, ‘jpeg’, ‘doc’,
‘xls’, ‘xml’, ‘txt’, ‘mpp’, ‘pdf’, ‘ppt’, ‘tiff’, ‘bmp’, ‘docx’, ‘xlsx’, ‘db’, ‘key’,
‘pptx’, ‘ps’, ‘odt’, ‘ods’, ‘odp’, ‘unf’, ‘cfg’, ‘zip’, ‘xml’, ‘odg’
);

$wgMaxUploadSize = 50000000;
$wgUploadSizeWarning - 0;
$wgVerifyMimeType = false;

$wgMSU_useDragDrop = true; // Should the drag & drop area be shown? (Not set by default)
$wgMSU_showAutoCat = true; // Files uploaded while editing a category page will be added to that category
$wgMSU_checkAutoCat = true; // Whether the checkbox for adding a category to a page is checked by default
$wgMSU_useMsLinks = false; // Insert links in Extension:MsLinks style?
$wgMSU_confirmReplace = true; // Show the “Replace file?” checkbox
$wgMSU_imgParams = ‘400px’; // The default size for images inserted on the edit page
$wgEnableWriteAPI = true; // Enable the API
$wgEnableUploads = true; // Enable uploads
$wgAllowJavaUploads = true; // Solves problem with Office 2007 and newer files (docx, xlsx, etc.)
$wgGroupPermissions[‘user’][‘upload’] = true; // Allow regular users to upload files
$wgDefaultUserOptions[‘usebetatoolbar’] = 1;

End of automatically generated settings.
Add more configuration options below.

##################################################################################

This should complete the editing of the LocalSettings.php file, save the changes and reload apache2

systemctl restart apache2

(optional) you can see the status of the apache2 process with

systemctl status apache2

This should complete the upgrade. Log into the Wiki server and try the standard and visual editors

#################################################################################

2 Likes

@lo.voltage oh wow that looks pretty good. Have attempted to upgrade previously but failed miserably. thanks for posting

really hate the way mediawiki works with respect to data input / updating / extensions but reading or retrieving my notes … soooooo much better

@lo.voltage Thank you very much for taking the time to provide such a details write up.
I will give this a try this week. :slight_smile:

@LTS_Tom did you removed the VM from your website?


When I click the link, I get redirected to the blog entry and no file is downloading

@fred974 It’s not that difficult to setup Mediawiki from a clean install (much harder to upgrade). The latest Mediawiki now has the visual editor included in case that is what you are looking for.

@neogrid so In order to get a simila version of what @LTS_Tom is provide is it just a case of installing Mediawiki on a VM and copy the settings from LocalSettings.php?

Just like Tom, I want to restrict the app to authorised user only via VNP access behind pfSense

I had this and this bookmarked, I’ve installed mine in a vm on headless debian 10. If you can setup LAMP, there are numerous guides on the web then it’s relatively painless.

During the install (I don’t fully recall) somewhere you need to ensure you don’t have an open wiki, so that you need a username and password to access the site. Once setup you can also enable 2FA from the wiki.

The last step you need to copy over the localsettings file that mediawiki generates. I use webmin which is a GUI for a headless machine that runs in a browser, which make it a bit easier to see the file structure.

All - hope you find the info usable. Posting it here was a challenge as the way I format my build/upgrade notes is interferes with the way the board software allows post to be formatted. Basically, I am old school and use Text editor as I don’t like anything messing with my ingrained ways of doing things. My raw notes use the same items used in mark down language. The other thing is I make sure to include in my build notes URL links for reference and in many cases to cite my references, and because I forget, so I’m not pulling things out of my @$$ lol. The URL links had to be removed. In the future for things like this, namely my build sheets, will consider posting my raw notes to something like pastebin.

While there is a lot of info here, it really doesn’t take long to do. It took longer to post the steps by a factor of 4 then it did to actually preform the upgrade.

If something is broken, please let me know and I will do my best to either correct it or help you work thru it.

@LTS_Tom Thanks for everything you do, was on the live chat this past Thursday. Giving back for all the things you have given us.

@neogrid

Yes the “documentation” on the MediaWiki website is a mess. Spent a few whole days sifting thru everything last year trying to understand the info to build my own MW server from scratch. I did reverse engineer Tom’s build to see how it was constructed. Combined what I knew about building Invoice Ninja instances and others into creating my own MW server from scratch on Debian 10.

You are correct that the MW VM is (at this moment) no longer available. In recent videos, Tom says they have moved the web host in house (IIRC). I have the image and could post it from Google Docs. Maybe @LTS_Tom will put the old one back up?

In the coming days I want to post my build sheet for constructing a new Debian 10 server MediaWiki build from scratch. Building the MW server from scratch is not too bad, just need edit out my swearing, clean up the formatting, grammar and spelling a bit.

@neogrid The LocalSettings.php can be edited with Webmin. It can be done with Nano or Vi (VIM) in the terminal as outlined in the steps above. Being I’m a Linux shop, I use SFTP to grab the file and modify it with Geany if I really needed too. I think WinSFP for Windows based users would work too. Configuring the “open wiki” happens during the first run of a new instance, during the setup wizard.

Enjoy!

2 Likes

There is a turnkey solution from Cloudron I have been previewing. Its a pretty sweet system and the bar to entry for both business and personal are very affordable. Its is a paid thing but does have a free version that supports 2 apps. Looking at this being one of our small business solutions especially for new businesses

  • Can run self-hosted or in a VPS
  • Can run as a VM (currently running in my XCP-ng core) or on physical hardware (colo)
  • Is basically a docker container host based on Ubuntu server 20 LTS with a web based front end
  • Web based apps are delivered via “Cloudron App Store”
  • Let’s Encrypt enabled
  • DNS APIs for ease of external DNS configuration with many popular hosts
  • It includes an optional email server, but works with external email like GMail
  • Some of the included apps are
  • Invoice Ninja (v4.5.35) Working to bring v5 of Invoice Ninja to the platform
  • MediWiki (v1.35.1)
  • Confluance (v7.11.1)
  • RocketChat (v.3.12.1)
  • Discorse ( v2.6.3)
  • Grafana (v7.4.3)
  • Nextcloud (v20.0.8)
  • NodeBB (1.16.2)
  • SyncThing (v1.14.0)
    Many many other things too

For Docker Devs

  • GitHub Pages (v212)
  • Docker Registry ( 2.7.1 (Registry UI 1.5.4))
    Even have the ability to build apps to be hosted on Cloudron
  • Cloudron Build Service

Seems to be professionally run, is actively supported and seems to have a polish that similar offerings do not have. Also they have an online live demo

2 Likes