Manual:Running MediaWiki on Ubuntu

Jump to: navigation, search
Translate this page; This page contains changes which are not marked for translation.

Other languages:
English • ‎español • ‎français • ‎日本語 • ‎한국어 • ‎polski

Installation guidesManual:Installation guide
FreeBSDManual:Running MediaWiki on FreeBSD
GNU/LinuxManual:Running MediaWiki on Linux
- ALT LinuxManual:Running MediaWiki on ALT Linux
- Arch LinuxManual:Running MediaWiki on Arch Linux
- DamnsmalllinuxManual:Running MediaWiki on Damnsmalllinux
- DebianManual:Running MediaWiki on Debian GNU/Linux
- FedoraManual:Running MediaWiki on Fedora
- GentooManual:Running MediaWiki on Gentoo Linux
- MandrivaManual:Running MediaWiki on Mandriva
- Red Hat Enterprise LinuxManual:Running MediaWiki on Red Hat Linux
- SlackwareManual:Running MediaWiki on Slackware Linux
- UbuntuManual:Running MediaWiki on Ubuntu
Mac OS XManual:Running MediaWiki on Mac OS X
NetWareManual:Running MediaWiki on NetWare
SolarisManual:Running MediaWiki on Solaris
- Solaris 11 / opensolarisManual:Running MediaWiki on Solaris 11 / opensolaris
- Solaris 10Manual:Running MediaWiki on Solaris 10
WindowsManual:Running MediaWiki on Windows
- Windows Server 2016Manual:Installing MediaWiki on Windows Server 2016
- Windows Server 2008Manual:Installing MediaWiki on Windows Server 2008
- Windows Server 2003Manual:Installing MediaWiki on Windows Server 2003
- Streamlined GuideManual:Streamlined Windows Install Guide
- Simple Windows/Apache GuideManual:Simple Windows Apache Installation
on a stickManual:Wiki on a stick
- MoWeS PortableManual:Installing on MoWeS Portable (Windows)
- Uniform ServerManual:Installation on Uniform Server (Windows)
- XAMPPManual:Installing MediaWiki on XAMPP
Sourceforge.netManual:Running MediaWiki on

This page explains how to install MediaWiki on an Ubuntu linux.

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.


Ubuntu Up-To-Date[edit]

Double check that Ubuntu is up-to-date by running:

sudo apt-get update
sudo apt-get upgrade

Install LAMP Stack[edit]

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 normal Ubuntu installation using these commands:

for Ubuntu with php7.0

  • NOTE: Before installing PHP 7.0 you must install following:
sudo apt-get install python-software-properties
sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update

Otherwise you won't be able to install PHP 7.0

sudo apt-get install apache2 mysql-server php7.0 php7.0-mysql libapache2-mod-php7.0 php7.0-xml

for Ubuntu with php5

sudo apt-get install apache2 mysql-server php5 php5-mysql libapache2-mod-php5

Opt. Useful Packages[edit]

These packages are not necessary but may be useful, depending on the installation:

php-apc Alternative PHP Cache.
php5-intl Unicode normalization.
imagemagick Image thumbnailing.
inkscape Alternative means of SVG thumbnailing, than ImageMagick. Sometimes it can better render SVGs originally created in Inkscape.
GD Library Alternative to ImageMagick. Install libgd2-xpm libgd2-xpm-dev php5-gd.
phpmyadmin MySQL administration tool.
vsftpd FTP Server. (How To)
php5-cli Ability to run PHP commands from the command line, which is useful for debugging and running maintenance scripts.


 sudo apt-get install php-apc php5-intl imagemagick phpmyadmin vsftpd php5-cli

Get MediaWiki[edit]

Warning Warning: The latest release of Ubuntu, 16.04, no longer packages MediaWiki. MediaWiki has to be manually installed. Previous versions of Ubuntu include a MediaWiki package, but it's MediaWiki version 1.19.x, for which support ended in May 2015. It is strongly recommended that MediaWiki be downloaded directly from download.

This can be done from a browser or by

    cd Downloads
  • extract in your Web directory
Ubuntu 14+: /var/lib/mediawiki
tar -xvzf /pathtofile/mediawiki-*.tar.gz
sudo mkdir /var/lib/mediawiki
sudo mv mediawiki-*/* /var/lib/mediawiki
Ubuntu < 14: /var/www/html
tar -xvzf /pathtofile/mediawiki-*.tar.gz
sudo mv mediawiki-*/* /var/www/html

Configure MySQL[edit]

Regular setup[edit]

Note 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 Warning: Remember this user (root) and password because you will need them when you configure MediaWiki.

Secure setup[edit]

Consider running mysql_secure_installation .

from main page:
This program enables you to improve the security of your MySQL installation in the following ways:
  • You can set a password for root accounts.
  • You can remove root accounts that are accessible from outside the local host.
  • You can remove anonymous-user accounts.
  • You can remove the test database (which by default can be accessed by all users, even anonymous users), and privileges that permit anyone to access databases with names that start with test_.

Optional: Configure PHP[edit]

These steps are optional and can be done post-installation. MediaWiki will still work without these changes.

Edit your PHP configuration file, php.ini. For Ubuntu 14.x it is at /etc/php5/apache2/php.ini. Depending on Ubuntu version it may be located at /etc/php5/php.ini or /etc/apache2/php/php.ini

sudo nano /etc/php5/apache2/php.ini

Maximum upload file size[edit]

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.

Memory limit[edit]

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 128M or more, leave it as is.

Configure Apache[edit]

Warning Warning: This section only applies if you installed MediaWiki using apt-get or aptitude, which is not recommended.
  • Edit apache.conf file at /etc/mediawiki/apache.conf
 sudo nano /etc/mediawiki/apache.conf

and un-comment this line:

Alias /mediawiki /var/lib/mediawiki

Save and exit out of the editor.

  • Verify that the Mediawiki configuration is in Apache. Edit the Apache2 configuration file
sudo nano /etc/apache2.conf


sudo nano /etc/apache2/apache2.conf

according to appropriate location.

Look for this line. Add it if is not present:

Include /etc/mediawiki/apache.conf
  • Restart Apache:
sudo apache2ctl restart


sudo service apache2 restart

Configure MediaWiki[edit]

Navigate your browser to http://localhost/mediawiki (for certain installations it may be http://localhost/mediawiki/config or instead) and following the procedure given.

If this gives a 404 error then this technique may work:

cd /var/www/html
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 creates a custom LocalSettings.php that must be moved to the parent directory of the new wiki. The configuration page will give the exact directory/filename that must be moved:

 sudo mv /var/lib/mediawiki/config/LocalSettings.php /var/lib/mediawiki

For added safety you can then remove the config subdirectory entirely:

sudo rm -rf config

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[edit]

General information[edit]

Mediawiki is configured by the LocalSettings.php file, usually found in /var/www/wiki. 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 /etc/mediawiki/LocalSettings.php

or from a terminal

sudo nano /etc/mediawiki/LocalSettings.php

File uploads[edit]

Enable uploads[edit]

By default, the Wiki will not permit images to be uploaded. To change this find $wgEnableUploads and change it from false to true.

Specifying uploadable file types[edit]

You may want to modify the list of accepted extensions, which is stored within the $wgFileExtensions array. For example, you will not be able to upload PDF files without making this change.

If $wgFileExtensions is not already in LocalSettings.php add it at the end (before the ?> line, if one exists in your LocalSettings.php file):

$wgFileExtensions = array('pdf','png','jpg','jpeg','ogg','doc','xls','ppt','mp3','sxc','nse');

In addition to the $wgFileExtensions option, the following settings may cause files to be rejected (even if $wgStrictFileExtensions = false; is set):

  • $wgFileBlacklist, a list of file extensions that are not uploadable
  • $wgMimeTypeBlacklist, a list of forbidden MIME types.

If problems are still encountered with uploads, check the includes/DefaultSettings.php file.

Image file uploads[edit]

The images directory must be writable: For Ubuntu 9.04 and newer, the command is:

sudo chmod a+w /var/lib/mediawiki/images

For older Ubuntu:

sudo chmod a+w /var/www/wiki/images

Enable thumbnails[edit]

The |thumb option added to an image: tag will automatically generate a thumbnail version of a picture — if support has been enabled, as follows:

  • As mentioned above in options, the ImageMagick package must be installed:
sudo apt-get install imagemagick
  • In LocalSettings.php, make sure the following settings are in place and not commented out.

They are normally about 80 lines down in the file marked "To enable image uploads":

$wgUseImageResize = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";


The $wgLogo variable specifies the graphical logo that gets displayed on the top left corner by default. However, the $wgLogo variable may not be present in LocalSettings.php by default - it must be added in manually to the bottom.

There is no standard for the size of the logo image, but 135x135 pixels will fit most skins. If the logo it is oversized for a specific skin it will show from the top left corner and clip the bottom/right of the image.

The logo file can be placed anywhere, but putting it in the top-level directory of the wiki is convenient. Fortunately, the variable $wgScriptPath contains the top directory of the wiki, so simply adding the following works well:

$wgLogo = "$wgScriptPath/wiki.jpg";
Warning Warning: Do not simply change the default logo installed with MediaWiki (/skins/common/images/wiki.png); this file will be overwritten when you upgrade.

MediaWiki extensions[edit]

Standard Extensions[edit]

The current installer for mediawiki comes with a package of 15 or so of the most popular extensions, but there are literally hundreds more. Go to for a complete list.

A list of the other "standard" extensions included with Ubuntu can be found by just running this command:

   ls /etc/mediawiki-extensions/extensions-available

Standard extensions can be installed with the mwenext command

sudo mwenext extensionname.php
  • Example: installing ParserFunctions
 sudo mwenext ParserFunctions.php

(If this fails the standard extension package needs to be installed with

 sudo apt-get install mediawiki-extensions


Once enabled, it should be listed as a symbolic link in /etc/mediawiki-extensions/extensions-enabled. You should now be able to go to http://localhost/mediawiki/index.php/Special:Version and see ParserFunctions listed there as an installed extension to your mediawiki. Confirm it's functioning by putting

3+5*2={{#expr: 3+5*2}}

on a wiki page and saving.

Other Extensions[edit]

Most MediaWiki extensions that are not available in the Ubuntu package system are downloaded in tarball (tar.gz) format and installed manually by putting the files into new subdirectory under extensions. The list of extensions is available here: Category:Extensions in Wikimedia version control

  • Download the tarball, unpack it to the "extensions" directory (on Ubuntu: "/var/lib/mediawiki/extensions")
  • Edit the "LocalSettings.php" (see above) to add a line reading
    require_once ("$IP/extensions/yourextension/yourextension.php");

Confirm you have installed it properly, by going to the Special pages in your wiki (link on left side) and choosing Version. All installed extensions are listed with versions, authors, and links to their home pages.

  • Example: installing MiniDonation

For an example, let's take the relatively simple extension called MiniDonation. This extension lets you put a <donationform> tag in your wiki code, and it will display a link to paypal on the page. The site for MiniDonation is here: Extension:MiniDonation

Download the tarball (save it to ~/Desktop), then unpack the files to the extensions directory:

cd /var/lib/mediawiki/extensions
sudo tar -zxvf ~/Desktop/MiniDonation

Next, modify LocalSettings with the Include directive specified in the instructions

sudo nano /etc/mediawiki/LocalSettings.php

Finally, check http://localhost/mediawiki/index.php/Special:Version - it should now list MiniDonation there. Edit a wikipage and add a <donationform> tag to it, save the page and a functional paypal button should be available.

Upgrading Extensions[edit]

  • Standard MediaWiki extensions (such as Cite.php) included in the mediawiki-exstensions package can be upgraded to a newer version.

The extension must be disabled using the command

mwdisext ExtensionName.php

before installing the files from the new version into the correct directory in /var/lib/mediawiki/extensions.

  • Manually installed extensions are upgraded by simply repeating the instructions, above, for installing other exstensions.
Warning Warning: Some versions of extensions will not work with certain versions of MediaWiki (or with other versions of other extensions that they depend upon). A "fatal error" will display when on certain MediaWiki pages (even including "Special:Version" page), or the wiki will not display any content at all.
Review the errors stored in /var/log/apache2/errors.log for a hint as to what is wrong.

Shortened URL[edit]

To use /wiki/* instead of /wiki/index.php/* on Ubuntu, follow the recommended short URL guide using '/mediawiki' as the script path instead of '/w' and placing the rewrites in /etc/apache2/conf.d/mediawiki.conf.

See also[edit]