How to create MediaWiki website
MediaWiki is free and open-source wiki software that can be used to build an encyclopedia, a knowledge base, an online journal, a documentation website, or a collaborative information project. The software itself is free, but a stable website still requires a correctly configured server, regular updates, backups, and careful management of user rights.
This article describes the basic process of creating a website with MediaWiki: choosing hosting, installing the software, configuring `LocalSettings.php`, installing skins and extensions, setting up short URLs, and safely updating the site.
About MediaWiki
MediaWiki is written mainly in PHP and was originally developed for Wikipedia. It is now used by Wikimedia Foundation projects and many independent websites.[1] The system is suitable for projects where pages are edited over time, linked to each other, categorized, and improved by several contributors.
MediaWiki is not a simple static website builder. It is a full wiki platform with page history, user accounts, permissions, namespaces, templates, categories, file uploads, and an extension system.
Installing MediaWiki
Before installation, decide what type of website you want to build: a public encyclopedia, a private knowledge base, a multilingual project, a file repository, or a compact reference website. This affects user rights, extensions, backup strategy, and hosting requirements.
A typical MediaWiki installation requires Apache or Nginx, PHP, a database such as MariaDB/MySQL, PostgreSQL or SQLite, and access to the website files. Always check the current requirements for the version you plan to install.[2]
Basic installation process:
- Check the official installation requirements.
- Download a stable MediaWiki release from the official download page.
- Create a database and database user.
- Upload MediaWiki files to the server using FTP/SFTP or SSH.
- Open the website in a browser and run the installation wizard.
- Save the generated `LocalSettings.php` file and upload it to the MediaWiki root directory.
- Test the main page, login, editing, and file upload.
The browser installer checks the environment, asks for database credentials, creates the first administrator account, and generates `LocalSettings.php`.[3] This file is the main configuration file of the website and should be backed up before changes.
Basic configuration
Common settings in `LocalSettings.php` include the site name, public URLs, uploads, user rights, email, default skin, short URLs, caching, and backups.
$wgEnableUploads = true;
$wgDefaultSkin = "vector-2022";
Skins
A MediaWiki visual theme is called a skin. Vector 2022 is the modern default skin, while Vector legacy, MonoBook, Timeless, MinervaNeue and other skins may also be used.[4] Skins are usually placed in `skins` and loaded from `LocalSettings.php`.
wfLoadSkin( 'Vector' );
$wgDefaultSkin = 'vector-2022';
Extensions
Extensions add new features to MediaWiki: visual editing, maps, parser functions, anti-spam tools, forms, file handling, forums, semantic data, and many other functions.[5] A typical installation includes downloading a compatible version, uploading it to `extensions`, adding a loading line to `LocalSettings.php`, running database updates if required, and checking `Special:Version`.
wfLoadExtension( 'ParserFunctions' );
Short URLs
By default, MediaWiki pages may use URLs such as `/index.php?title=Page_title`. Public websites usually use shorter addresses such as `/wiki/Page_title`. Short URLs require both MediaWiki settings and web server rewrite rules.[6]
$wgScriptPath = "/w";
$wgArticlePath = "/wiki/$1";
Updating MediaWiki
MediaWiki should be updated regularly to receive security fixes, bug fixes, and compatibility improvements. Before updating, make a database backup, a file backup, check the requirements of the new version, and prepare compatible versions of extensions and skins.[7]
cd /path/to/mediawiki
mysqldump -u db_user -p db_name > backup.sql
cd ..
tar -czf mediawiki-files-backup.tar.gz mediawiki
wget https://releases.wikimedia.org/mediawiki/1.43/mediawiki-1.43.5.tar.gz
tar -xzf mediawiki-1.43.5.tar.gz
cp mediawiki/LocalSettings.php mediawiki-1.43.5/
rsync -a mediawiki/images/ mediawiki-1.43.5/images/
cd mediawiki-1.43.5
php maintenance/run.php update
Older manuals often use `php maintenance/update.php`; in modern MediaWiki versions, maintenance scripts are preferably run through `maintenance/run.php`.
