MediaWiki administration
| tbd @ |
|---|
Background
This page contains some knowledge collected by me in my years of acting as a MediaWiki administrator. I am not a coder (yet), so do not follow any advice on here blindly.
If performance turns out to be an issue, have a look at Manual:Performance tuning. Not mentioned there: Replacing {{SITNAME}} in MediaWiki:Aboutsite and MediaWiki:Pagetitle with the name of your wiki will reduce processing time a tiny bit on each hit, because the "magic word" does not have to be processed. (Found on User:Aaron Schulz/How to make MediaWiki fast)
One thing to note: There is a Firefox AddOn called universal-edit-button, which adds a button to the URL to start editing the page you are viewing, if it is part of a MediaWiki.
MediaWiki uses Wikitext, which is converted into html by the parser. Thus knowing a bit about html can be beneficial when editing a MediaWiki. selfhtml.org (German website) is a great place to start learning html, while sitepoint.com has many articles about specific topics.
File Structure
Common Structure
These folders and files are useful for any website.
| Folder / File | Function | Path (example) | Useful Links | Notes |
|---|---|---|---|---|
| FTP root | basic folder accessible through FTP | /var/www/vhosts/mywebsite.example/
|
everything in this folder can be accessed with a FTP-client by an authorized user | |
| web root | basic folder accessible through the web | /var/www/vhosts/mywebsite.example/httpdocs/
|
requests to mywebsite.example will be answered with whatever is configured in this folder
| |
| backups | folder containing the #Backups of the website | /var/www/vhosts/mywebsite.example/backups/
|
backups should never be in the web root | |
| logs | folder containing the access logs of the website | /var/www/vhosts/mywebsite.example/logs/
|
access logs should never be in the web root | |
| confidential | folder containing confidential data like access passwords for databases | /var/www/vhosts/mywebsite.example/confidential/
|
Manual:Securing database passwords | this confidential data can be included where needed confidential data should never be in the web root |
| sitemap | folder containing the Sitemap | /var/www/vhosts/mywebsite.example/httpdocs/sitemap/
|
Manual:generateSitemap.php | the sitemap needs to be accessible through the web the location of the sitemap can be announced to web crawlers in robots.txt |
| bot-trap | folder containing the Bot-trap | /var/www/vhosts/mywebsite.example/httpdocs/bot-trap/
|
Bot-trap | the bot-trap needs to be accessible through the web |
| .htaccess | file containing access-rules to the folder for web requests | /var/www/vhosts/mywebsite.example/httpdocs/.htaccess
|
Ultimate htaccess mod rewrite rewrite-tester htaccess examples |
a .htaccess file can be defined for every folder in web root |
| robots.txt | file containing access-rules for bot requests | /var/www/vhosts/mywebsite.example/httpdocs/robots.txt
|
Manual:robots.txt | these rules are not enforced by the web server; enforcement will have to be done through .htaccess and the Bot-trap |
MediaWiki-specific Structure
These folders and files are specific to MediaWiki.
| Folder / File | Function | Path (example) | Useful Links | Notes |
|---|---|---|---|---|
| MediaWiki | folder containing the files of the MediaWiki installation | /var/www/vhosts/mywebsite.example/httpdocs/w/
|
Download Manual:Installing MediaWiki |
it is possible, but not advisable, to install MediaWiki directly in the web root: Manual:Wiki in site root directory |
| images | folder containing all files uploaded to the wiki | /var/www/vhosts/mywebsite.example/httpdocs/w/images/
|
Manual:Configuring file uploads | this folder needs to be retained during an #Upgrade, otherwise files which were uploaded to the Wiki will be lost |
| extensions | folder containing all MediaWiki extensions | /var/www/vhosts/mywebsite.example/httpdocs/w/extensions/
|
Manual:Extensions Wiki Aventurica:Extensions |
Certain extensions are bundled with every MediaWiki download, these only need to be activated in LocalSettings.php. Many others need to be downloaded into the extensions folder first. |
| cache | folder containing the cache of the wiki | /var/www/vhosts/mywebsite.example/httpdocs/cache/
|
Manual:Cache Localsettings |
Keeping the cache files outside of the MediaWiki folder will enable smaller and faster #Backups, because the cache does not need to be backed up. |
| custom | folder containing all your custom files | /var/www/vhosts/mywebsite.example/httpdocs/custom/
|
Custom files | Keeping all your custom files outside of the MediaWiki folder will enable faster #Upgrades, because you will not have to worry about losing files when switching folders. Examples for custom files would be php files which you include into LocalSettings.php, and your Wiki's logo. |
| LocalSettings.php | file containing the configuration of the Wiki | /var/www/vhosts/mywebsite.example/httpdocs/w/LocalSettings.php
|
Manual:LocalSettings.php Manual:Configuration settings Manual:Hooks Localsettings |
This is the file central to the configuration of your Wiki. Here you can change variables, define and configure the extensions which should be used, use hooks, and include code from other files. Most commonly used: Manual:Short URL/Apache
$wgScriptPath = "/w"; #MediaWiki folder
$wgArticlePath = "/wiki/$1";
|
Administrative Tasks
Installation
see #Upgrade, or Manual:Installing MediaWiki
Using Xampp, it is possible to set up a wiki on your personal computer, see Manual:Installing MediaWiki on XAMPP.
Backup
A Backup of a MediaWiki consists of
- the database
- the MediaWiki folder (more precise: the
/imagesfolder and all customized files, especiallyLocalSettings.php)
In addition, it is possible to dump the contents of the Wiki in XML format.
Furthermore, it is of course important to know how to recreate the Wiki from a backup.
For compressing / decompressing a backup, see Web server administration#Working with Code.
| Aspect | MediaWiki Link | Useful Links | Notes |
|---|---|---|---|
| backup database | Manual:Backing up a wiki | Import and Export Databases in MySQL or MariaDB mariadb-dump documentation InnoDB Backup documentation |
There are two ways to create a backup of the database:
An example for a script which uses both options can be found at Backup script. It is advisable to always check if the backup was actually created - in some cases the backup file will be empty if an error occured. |
| backup file system | Manual:Backing up a wiki | tar | tar combines multiple files into one and thus can be used to create a backup of a folder. It is advisable to also compress this tar-file with gzip.
This example creates a backup of the web root folder: If there is no SSH access, file backup needs to be done through FTP. |
| backup wiki content | Manual:dumpBackup.php | Manual:Importing XML dumps | Runnung dumpBackup.php from the command line requires SSH access; it exports wiki pages, but not user accounts, files or deleted page revisions - thus it is impossible to fully recreate a wiki with this dump.
#all page versions
php dumpBackup.php --full > dump.xml
#only current page versions
php dumpBackup.php --current > dumpcurrent.xml
|
| restoring a Wiki from backup | Manual:Restoring a wiki from backup | Archive unter Linux (tar, gz, bz2, zip) Importieren großer Datenbanken unter xampp mysqldumpsplitter key_buffer_size max_allowed_packet |
Ideally, you would never need to do this, except if you change servers.
The backup is probably compressed and thus needs to be decompressed first. mysql -u wikidb_user -p wikidb < dump_of_wikidb.sql
If the backup is large, import might take too long if Also, |
Maintenance scripts
SSH access is required for running the Manual:Maintenance scripts from the command line. Most of the scripts should not necessary, but some scripts should run regularly (using Cron or Systemd).
| Script | MediaWiki Link | Useful Links | Frequency | Notes |
|---|---|---|---|---|
| runJobs.php | Manual:Job queue | 10 minutes | This script works on the job queue. It is advisable to run it regularly, using Cron or Systemd.
php maintenance/run.php runJobs --maxtime 600 | |
| rebuildall.php | when needed | This script updates categories, links, file usage and the search index for all pages in the wiki. These updates happen for a page if a new version of that page is saved, so usually it should not be necessary to run this script.
php maintenance/run.php rebuildall | ||
| delete html file cache | Manual:File cache purgePage.php |
1 month | The html code of every page is saved and served to anonymous users until the page is edited (so possibly indefinitely), so it is advisable to delete this cache from time to time. Sadly, there is no maintenance script for this, so we use the following command:
find /var/www/vhosts/mywebsite.example/httpdocs/cache/html -type f -delete If there is a page (or a list of pages) which you want refreshed more frequently, you could use: php maintenance/run.php purgePage < /var/www/vhosts/mywebsite.example/httpdocs/custom/purgedaily.txt |
Upgrade
Unfortunately, in MediaWiki there is no Upgrade script that will automate the whole process for you, so you will basically have to do a reinstall every time you upgrade your Wiki. Items in the following list which are only necessary during an upgrade will be marked with (*).
- (*) #Backup the Wiki
- Download the new version of MediaWiki and the corresponding versions of all Extensions that are not bundled
- Move the files of the new version onto the server
- (*) Rename the folder with the files of the old MediaWiki version
- Create a folder with a name of your choosing (
/w/is suggested) - Move the files of the new MediaWiki version (along with the new versions of all extensions) into the new folder
- (*) move the
imagesfolder and all custom files (especiallyLocalSettings.php) from the old folder into the new folder - do the database update (the database must exist already)
- either use the webinstaller: Access the URL
yourwebsite.example/mw-config/index.phpwith your browser and follow the instructions there. This method may timeout if a large database needs to be updated, but the webinstaller will generate a new Localsettings for you. - or use SSH: Run update.php from the command line. Updating Localsettings will be up to you.
- either use the webinstaller: Access the URL
- If you used the webinstaller, you will have to move the generated
LocalSettings.phpto the MediaWiki folder. After that, the Wiki should be functional (again).
If errors occur during the database update or when accessing the Wiki after the upgrade, most of the time extensions or outdated Localsettings are responsible. Analyzing these errors and fixing bugs is usually the most time-consuming task of the upgrade process, which is the reason why it is advisable to test the upgrade on a separate testwiki.
Bugfixes used on Wiki Aventurica can be found at Bugfixes.
Something to note: The webinstaller has an option enabled by default which will lead to the Wiki sending data about it to a MediaWiki-Server, see Manual:$wgPingback. If you forgot to opt-out during the upgrade process, it is possible to fix this by adding $wgPingback = false; to the Localsettings.
Rules and Regulations
No matter where your server is located, there are probably some laws defining what you should or should not do with your website. In Germany, for example, we need to have an Impressum, and we need to inform our visitors about our Privacy policy.
But if you are running a wiki which can be edited by other people, it also is a good idea to craft some rules for the community of your editors - terms of service (TOS), so to speak (in Germany called Allgemeine Geschäftsbedingungen (AGB), which is of course a bit misleading for non-profit websites).
Those rules should clarify:
- which kind of content the wiki is for
- how the content should be presented
- and what kind of behavior is expected from the editors
It is possible to make every new editor confirm those rules while creating a new account, if the Extension:NewSignupPage is installed and properly configured, see MediaWiki Extensions.
It is also possible to ask every user for confirmation every time those rules are changed, by installing and properly configuring Extension:UserAgreement (see Bugfixes/MediaWiki_1.45#Extension:UserAgreement_(2.0.0)).
examples at Wiki Aventurica
- Projektinhalt
- Format der Artikel
- Nutzerverhalten