Install Mediawiki

From XPUB & Lens-Based wiki
(Redirected from Mediawiki)

Setting up your own Mediawiki.

Which wiki?

There are many different kinds of wiki softwares around:

For this page we will focus on installing MediaWiki.

Where is your wiki?

click and install

Most regular web hosting companies allow for installing MediaWiki without too much trouble, although maintaining and upgrading the code would still in most cases be up to you.

"wiki-family" or "wiki farm"

If you want to run a MediaWiki wiki and don't want to maintain your own infrastructure, you might be interested in a wiki-family or wiki farm.

One of those wiki hosting providers is Fandom (earlier called Wikicities and Wikia), see:

For more information and a list of wiki farms see:

on your own server

If you want to install a wiki on your own server, you can follow the steps on this page.

For notes on how to choose what kind of server you would like to work with and how to install it, see:


Mediawiki requires 3 things to be installed:

  • PHP
  • webserver (like nginx or apache)
  • database (MariaDB, MySQL, SQLite or PostgreSQL)

Check the Mediawiki download page to see which exact versions you need:

Install a database

For this example we will use MariaDB.

$ sudo apt install mariadb-server

Install a webserver

For this example we will use nginx.

$ sudo apt install nginx

Install PHP

Install PHP + the fpm and php-mysql extension:

$ sudo apt install php php-common php-fpm php-mysql php-mbstring php-xml php-intl

Configure your webserver to work with the fpm extension.

For example, when you work with nginx, edit the default config file with:

$ sudo nano /etc/nginx/sites-enabled/default

and add the following snippet:

Note: change the version number of php to your installed version!

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.3-fpm.sock;

First test if the nginx if oke:

sudo nginx -t 

And now reload nginx to apply the changes you made to this config file:

$ sudo service nginx reload

To see if php works now, you can make a php file in /var/www/html/ called test.php:




Now open this file in the browser and see if it works.

Download Mediawiki

Navigate to the folder where you want to install Mediawiki.

In this example we will install it at /var/www/wiki/:

cd /var/www/wiki/

Download the latest version of Mediawiki and unzip the tar file.

You can copy the link from the Mediawiki download page:

tar xf mediawiki-1.38.4.tar.gz

Rename the wiki folder something short, like "wiki".

mv mediawiki-1.38.4 wiki

Configure the URL

To connect the folder /var/www/wiki/ to an url like we need to edit the configuration file of the webserver.

$ sudo nano /etc/nginx/sites-enabled/default

Add the following lines:

location /wiki {
    alias /var/www/wiki/;
    index index.php;

See if it works:


By default you can log in to MariaDB with the root user and the root password.

However, it's a *good idea* to create a dedicated database + database user for your wiki. In this way you can easily back it up (and eventually restore it) with a simple mysqldump command. Also, it helps to keep different projects separate from each other. See the Mysql page on how to do this. Once you do this add the database name, user name, and password to the Mediawiki setup page when requested.

We will now make a dedicated database for your wiki.

First log in into MariaDB as root:

$ sudo mysql -u root 

Create a new database:

(Note: replace "NAMEOFYOURDATABASE" with the name of your wiki, for example: mywiki.)


Create a dedicated user for this database and assign a password.

Write this password down, you will need it later to configure the wiki.

(Note: replace "USERNAME" and "SOMEPASSWORD" with something else.)


Give this user the rights to edit the database:


Check if it worked:


Exit MariaDB:


Setup your Mediawiki

Now go to the wiki setup script:

(Or wherever you installed your wiki of course!)

In step 2 you can use your database settings as configured in the above step. The database prefix can be left empty.

Give the wiki a name and fill in the administrator account info. When in doubt, leave things at the default values.

At the end, download the LocalSettings.php file.

Upload LocalSettings.php

Upload the LocalSettings.php file you just downloaded to the folder of your wiki: /var/www/wiki/.

The wiki should work now!

Try it out by opening your wiki:

Point your browser to the URL of your wiki, and see if it works!

NOTE: Special:Version is a useful page to see the metadat of your wiki!

When installing the wiki on a sandbox server

However for a sandbox server you have to tweak one line in the LocalSettings.php file.

Open the file with a text editor (like nano) and look for:

 $wgScriptPath = "/wiki";

and change it to:

 $wgScriptPath = "/soupboat/wiki";

Enable uploads

Enable uploads in your LocalSettings.php:

$wgEnableUploads = true; # Enable uploads

and change permissions of the images folder:

$ sudo chgrp www-data /var/www/wiki/images
$ sudo chmod 775 /var/www/wiki/images


Change upload size

You can change the upload size limit in the php.ini file (this is the configuration file for php).

See where it is at the server with:

$ php --ini

Open the php.ini file with nano:

$ sudo nano /path/to/file/php.ini

Search for upload_max_filesize and post_max_size and change the values to your desired upload size, for example to: 32M

Since we're running php through fpm, we need to restart the php-fpm service to apply these changes.

Check which version you are running:

$ sudo service --status-all

Then restart the service, replace "X" with the version number you are using:

$ sudo service php7.X-fpm restart

Next to this, you also need to configure the upload size in your LocalSettings.php file, add the following:


Try to upload a file to see if it works.

Who is editing?

How open/closed do you want your wiki to be?

  • public, everyone can edit
  • public, only people with accounts can edit, account creation is open
  • public, only people with accounts can edit, account creation is closed
  • non-public, only you can edit

Back up your wiki

You can make a copy of the wiki's database with mysqldump:

$ mysqldump -u DBUSER DBNAME > DBNAME.sql

Next to the database, you will also need to back up:

  • LocalSettings.php
  • images/
  • extension/

You can compress these files into one .tar file:

$ tar -czvf backup.tar.gz DBNAME.sql LocalSettings.php images extensions

This is your back up now, you can move it to a safe place, for example another computer/hard drive/usb stick/...

When you need the files, you can extract this tar file again with:

$ tar -xzvf backup.tar.gz


You can find lists of extensions on the MediaWiki wiki:

There are instructions on the MediaWiki page of the extension about the installations.

But basically you follow the following steps.

Copy the extension to:


And then activate it in your LocalSettings.php:


with the following line:


If it is installed correctly, it should show up on this page:



Choose a skin

See: +

You can find instructions regarding how to install the skin on the MediaWiki page for the skin, for example this is the page for the Vector skin:

Tweaking the skin

You can edit the CSS of the skin at this wiki page: MediaWiki:Common.css

And leave javascript code here: MediaWiki:Common.js

Customize text and menu's

Edit the menu: MediaWiki:Sidebar

Edit system texts:

You can find all system texts at:


See also