Manual:Running MediaWiki on Debian or Ubuntu

This guide is to help other users manually install MediaWiki on an Ubuntu installation using primarily command-line interface commands from a command line Terminal. These instructions are applicable to recent versions of both the Ubuntu Server and Desktop editions.

To install MediaWiki on an older (and potentially outdated) version of the Ubuntu Desktop Edition (primarily using the Gnome Desktop and Synaptic Package Manager), see this page.

Manual setup can sometimes be difficult and time consuming. A few users may want to consider using TurnKey MediaWiki, a third party software appliance based on Ubuntu 8.04.1 (Hardy).

Step-By-Step
Ubuntu server edition comes with an option to install and configure a LAMP server (which includes an integrated combination of Apache, MySQL, PHP) at the time of initial installation. However, you can also install a LAMP server anytime in either the Server edition or the Desktop edition with the command: sudo tasksel install lamp-server

If you want to use the GD library (instead of ImageMagick for image manipulation), you can also install:

sudo apt-get install php5-gd

Configure MySQL
This step is not necessary if you were prompted to create a mysql root password during MySQL (LAMP) installation in the previous step.


 * Set up a mysql root password. It is best not to use the same password for system root and mysql root.

mysqladmin -u root password ""

Note: Remember this user (root) and password because you will need them when you configure MediaWiki.

history -c
 * (Optional:) Clear your command history so that other users cannot get to your password.

Configure PHP
''These steps are optional. You can skip them entirely (or do them later) and MediaWiki will still work fine.''

Edit your php configuration file. It will be located somewhere like  or   or maybe

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

Maximum Upload Filesize
Assuming that various files are going to be uploaded to the Wiki as content, the limit on the maximum size of an upload can be adjusted. About halfway down is the File Uploads section. Change: upload_max_filesize = 2M to at least 8M if you will be uploading large files. You may have to adjust this again in the future. upload_max_filesize = 8M

Memory Limit
Some PHP scripts require a lot of memory to run. To increase the maximum amount of memory a script can use, change the following entry, if found, from memory_limit = 20M to memory_limit = 32M

Extensions
NOTE: Using later versions of MediaWiki and Ubuntu, this section is unnecessary.

PHP MySQL support has to be enabled. Page down a bit further and make sure the following line is uncommented: extension=mysql.so

If you use the GD graphics library to do image resizing (instead of ImageMagick), also uncomment: extension=gd.so

Save and exit out of the editor and restart Apache: sudo apache2ctl restart

Configure MediaWiki
sudo gedit /etc/mediawiki/apache.conf and uncomment the line: Alias /mediawiki /var/lib/mediawiki
 * Edit apache.conf file at /etc/mediawiki/apache.conf

sudo apache2ctl restart
 * Restart Apache:


 * Navigate your browser to http://localhost/mediawiki, to http://localhost/mediawiki/config, or to http://wiki.hostname.org/config and continue with the installation.

Pay close attention to "Checking environment..." during the MediaWiki installation script execution. This can solve a lot of problems in successfully installing MediaWiki by identifying the source of 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 use the "Use superuser account" (which is the MySQL username "root") and the MySQL root password you configured earlier, above.

sudo chmod a+rwx /var/lib/mediawiki/config sudo mv /var/lib/mediawiki/config/LocalSettings.php /etc/mediawiki For added safety you can then remove the config subdirectory entirely: sudo mv config/LocalSettings.php. sudo rm -rf config
 * Once configuration is done you'll need to move the created LocalSettings.php to the parent directory. The configuration page will have the exact directory/filename that must be moved:


 * Navigate your browser to http://server_address/wiki or to http://server_address/wiki/index.php to see your new wiki. If server_address = localhost, then http://localhost/wiki should work.

General Information
In Ubuntu 9.04, MediaWiki is installed at /usr/share/mediawiki. However, configuration/customizations are actually installed in /var/lib/mediawiki.

Confusingly, links are created in both locations so all files appear to be in both places.

Additional Wiki Configuration
The Wiki 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 sudo gedit /etc/mediawiki/LocalSettings.php

Enable Uploads
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 Filetypes
You may want to modify the list of accepted extensions, which is stored within the $wgFileExtensions array. By default you will not be able to upload PDF files, for example, 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):

Images Uploads
The images directory must be writeable: sudo chmod a+w /var/www/wiki/images

Note: for Ubuntu 9.04 the command is: sudo chmod a+w /var/lib/mediawiki/images


 * I just did a clean install into Ubuntu 8.04 LTS, and making the images directory writable was not required in order for image uploading to work. Seems like this step is superfluous and a little dangerous. --Mark 16:59, 22 September 2009 (UTC)


 * I just did a clean install into Ubuntu 8.04.3 LTS, and making the images directory writeable was required to get SVG graphics to work. I don't see how it is dangerous to allow the WWW user to write to the images folder (?).

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

sudo aptitude install imagemagick
 * The ImageMagick package must be installed:


 * 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":

Changing The Logo
The $wgLogo variable specifies the the graphical logo that gets displayed on the top left corner by default. The variable $wgScriptPath contains the top directory of the wiki - in this case /var/www/wiki. The logo image is supposed to be 135x135 pixels; if it is oversized it will show the top left corner that fits.