Manual:Running MediaWiki on Debian or Ubuntu
|It has been suggested that this page or section be merged with Manual:Installing MediaWiki. (Discuss)|
This page explains how to install MediaWiki on a Debian or Ubuntu GNU/Linux server. The instructions below refer to Debian, but unless otherwise noted also apply to Ubuntu.
This installation procedure requires knowledge of issuing commands from a terminal (e.g. installing applications) and using a text editor (e.g. graphical: gedit, kate; text: nano, emacs, vi).
When text editing is required it can be carried out on the graphical desktop by pressing Alt-F2 and typing
gksudo gedit filename
Alternatively, editing can be done from a terminal
sudo nano filename
Of course, kate could be used instead of gedit or vi instead of nano.
- 1 Step-By-Step
- 2 Additional wiki configuration
- 3 See also
Ensure Debian is up-to-date
Double check that Debian is up-to-date by running:
sudo apt-get update sudo apt-get upgrade
Install LAMP Stack
Ubuntu Server Edition makes LAMP (Apache, PHP, and MySQL) available for installation during the install process. During the installation step, make sure you choose to install a LAMP server. Alternately, you can install all of these packages from a standard installation using these commands:
Note: Ubuntu Xenial and Debian Stretch include PHP 7.0, and renamed many packages from "php5" to plain "php". In addition, some PHP modules are now in separate packages (xml, mbstring).
sudo apt-get install apache2 mysql-server php php-mysql libapache2-mod-php php-xml php-mbstring
Note: Ubuntu Trusty and Debian Jessie include PHP 5, and use "php5" in most (but not all) packages.
sudo apt-get install apache2 mysql-server php5 php5-mysql libapache2-mod-php5
Optional useful packages
These packages are not necessary but may be useful, depending on the installation:
|Alternative PHP Cache||php-apcu||Modern MediaWiki versions will automatically take advantage of this being installed for improved performance.|
|PHP Unicode normalization||php-intl or php5-intl||MediaWiki will fallback to a slower PHP implementation if not available.|
|Inkscape||inkscape||Alternative means of SVG thumbnailing, than ImageMagick. Sometimes it will render SVGs better if originally created in Inkscape.|
|PHP GD library||php-gd or php5-gd||Alternative to ImageMagick for image thumbnailing.|
|PHP command-line||php-cli or php5-cli||Ability to run PHP commands from the command line, which is useful for debugging and running maintenance scripts.|
You can install any of the above with
sudo apt-get install packagename.
- Download the official tarball
This can be done from a browser or by
cd Downloads wget https://releases.wikimedia.org/mediawiki/1.27/mediawiki-1.27.1.tar.gz
- extract in your Web directory
tar -xvzf /pathtofile/mediawiki-*.tar.gz sudo mkdir /var/lib/mediawiki sudo mv mediawiki-*/* /var/lib/mediawiki
Note: This step is not necessary if you were prompted to create a mysql root password during MySQL installation.
First, set up a mysql root password. Remember not to use same password for system root and mysql root. This will also clear your command history so that other users cannot get to your password.
mysqladmin -u root password "<enter the new password here>" history -c
|Warning:||Remember this user (root) and password because you will need them when you configure MediaWiki.|
Consider running mysql_secure_installation .
- from main page:
|This program enables you to improve the security of your MySQL installation in the following ways:
Optional: Configure PHP
Edit your PHP configuration file, php.ini. On Ubuntu Trusty and Debian Jessie, it is located at
On Ubuntu Xenial and Debian Stretch (PHP 7), it is located at
Maximum upload file size
Assuming that various files are going to be uploaded to the Wiki as content, the limit on the maximum size of an upload has to be adjusted. About one-half way down is the File Uploads section. Change:
upload_max_filesize = 2M
to at least 20M. You may have to adjust this again in the future if you want bigger uploads.
Some PHP scripts require a lot of memory to run. To increase the maximum amount of memory a script can use, page down to about 21%, and change the following entry, if found, from
memory_limit = 8M
memory_limit = 128M
If it is already set to 128M or more, leave it as is.
Navigate your browser to http://localhost/mediawiki (for certain installations it may be http://localhost/mediawiki/config or http://wiki.hostname.com/config instead) and following the procedure given.
If this gives a 404 error then this technique may work:
sudo ln -s /var/lib/mediawiki mediawiki
- Pay close attention for "Checking environment..." in MediaWiki installation script.
This can solve a lot of problems by specifically identifying the source of any errors. Fill out the configuration form and continue.
Under Database Config, you may change the database name and DB username to new values, but you must turn on "Use superuser account", name:
giving the mysql root password you configured earlier.
The configuration process will prompt you to download a LocalSettings.php that must be saved to the parent directory of the new wiki. The configuration page will give the exact directory/filename that must be moved:
sudo mv ~/Downloads/LocalSettings.php /var/lib/mediawiki/
And navigate your browser to http://localhost/mediawiki (or http://server_ip_address/mediawiki or http://server_ip_address/mediawiki/index.php) to see your new wiki.
Done! You now have a working Wiki
Additional wiki configuration
Mediawiki is configured by the LocalSettings.php file, usually found in
/var/lib/mediawiki. Manual:LocalSettings.php has detailed information that may be useful. The following are changes that appear to be universally helpful
To edit LocalSettings.php use
gksudo gedit /var/lib/mediawiki/LocalSettings.php
or from a terminal
sudo nano /var/lib/mediawiki/LocalSettings.php
Changing the logo
The current tarball for Mediawiki comes with a package of 15 or so of the most popular extensions, but there are literally hundreds more.
Instructions on how to enable extensions can be found at Manual:Extensions#Installing_an_extension.
To use /wiki/* instead of /wiki/index.php/* on Debian, follow the recommended short URL guide using
'/mediawiki' as the script path instead of
'/w' and placing the rewrites in /etc/apache2/conf-enabled/mediawiki.conf.
- Canonical maintains a MediaWiki page with more information
- Debian MediaWiki page
- Ubuntuguide.org provides detailed instructions for setting up MediaWiki on Ubuntu and Kubuntu, including multiple wikis and nested subwikis.
- Start to end Mediawiki Setup Guide at ofswiki.org, closely referencing official docs, support for multiple distros including Debian/Ubuntu, automation and a minimal style