A Guide to Configuring MediaWiki in a hosted environment
This article is part of a series compiled as a guide to encourage and assist those building a MediaWiki-based website in a hosted environment.
Each article links to relevant documentation from the MediaWiki.org website and the Wikimedia.org website. Where the official documentation does not adequately cover the issues for a hosted site, or is too 'advanced', additional information, explanation and advice is provided.
All configuration requires access to, and editing of, the file named LocalSettings.php.
To locate this file use the interface to your web hosting provider and navigate to the directory /w.
Make a copy of this file so you have a backup.
The Manual:LocalSettings.php provides information on common settings but before making any changes there are two Initial Tasks that should be considered first -see below. Other important configuration items follow.
Manuals and Links
1. Restrict Anonymous Access
Before you go any further with configuration, a most important step is to prevent anonymous users from registering. By default, anyone can create an account and become a user on a new installation of MediaWiki. If your website is public that can expose you to spam and other unwanted user activity.
The lines below are part only of a security configuration recommended in the Manual:Using MediaWiki as a content management system. For an explanation of $wgGroupPermissions see the Manual. Security is covered in more detail in another article. At this stage though, it is wise to add the following to your LocalSettings.php file.
#Stricter than normal settings: #prevent anonymous users from registering $wgGroupPermissions['*']['createaccount'] = false; #prevent anonymous users from editing $wgGroupPermissions['*']['edit'] = false; $wgGroupPermissions['*']['createpage'] = false; #disable section edit links for anonymous viewers $wgDefaultUserOptions['editsection'] = false; #remove userpage & usertalk links for anonymous $wgShowIPinHeader = false;
2. Run the configuration script mw-config
An explanation of the configuration script supplied with MediaWiki, mw-config, is covered in A Guide to using the MediaWiki configuration script mw-config.
Setting the default Skin
Several skins are provided with MediaWiki and others are available for download.
Although only one Skin can be set as the default skin, one or more skins can be loaded, so that users can choose the skin according to their own preference, if enabled.
It is simpler, however, to load and enable only one Skin and then everyone sees the site the same way.
The default skin is set by the variable $wgDefaultSkin like this:-
$wgDefaultSkin = 'vector';
Some versions of MediaWiki did not register a skin so this had to be done as part of the initial configuration after installation. The most recent versions seem to have restored the default setting in LocalSettings.php.
A more complete guide is linked in the article Install and Configure Skins.
Configure Short URLs
MediaWiki URLs look like this, by default:
A Short URL hides the php file extensions from the page address, and replaces the installation path /w with a virtual directory /wiki (that doesn't actually exist), so the page URL typically looks like this:
The Guide to using Short URLs for MediaWiki Pages explains how to achieve this.
Use and Customise WikiEditor
The Extension WikiEditor should already be in the /w/extensions directory. To load it, the following line should be in the LocalSettings.php file:-
wfLoadExtension( 'WikiEditor' );
To use and configure the beta toolbar the following lines are also suggested in the article Extension:WikiEditor
# Enable use of beta toolbar for all users. Users cannot disable it. $wgHiddenPrefs = 'usebetatoolbar'; # Ensure beta toolbar is loaded (for versions prior to MW version 1.31) $wgDefaultUserOptions['usebetatoolbar'] = 1;
MediaWiki versions prior to 1.31 may also need the following lines:-
# Display the Preview and Changes tabs $wgDefaultUserOptions['wikieditor-preview'] = 1; # Display the Publish and Cancel buttons on the top right side $wgDefaultUserOptions['wikieditor-publish'] = 1;
Other Configuration Items
The list of configurable items is quite extensive: some are listed below:
- Site Name and Logo
- Refer to the Manual:LocalSettings.php for common settings, such as the Site Name and use of a Logo.
- A very useful feature of MediaWiki is the use of Subpages. This is turned off, by default, in the Main namespace, but can be enabled. This website is using sub-pages, for example. See the article Help:Subpages for more information.
- Another important feature in MediaWiki is the concept of Namespaces. See A Guide to configuring Namespaces in MediaWiki for details.
- Extensions add features and functionality to MediaWiki. See the article Install and Configure Extensions for a more complete guide to installing and configuring MediaWiki Extensions in a hosted environment.
The information or advice provided in this Guide is based on, or links to, official documentation for MediaWiki and was accurate when this article was created. However, some variation may occur between versions of MediaWiki; and the specifics of web hosting varies by service provider. Consequently, you should always create an effective backup before making any changes; ensure that you can restore your database and website; read the Release Notes before upgrading; and apply best practices to the management of your website. Any action that you take based on information provided here is at your own risk and the author accepts no liability for any loss or damage.