Wikibase/Installation

This page provides step-by-step instructions for installing a basic, minimal version of Wikibase. If you're interested in more advanced configurations, please refer to the advanced configuration guide. More detailed documentation bound to each version of the code can be found in the docs folder of the Wikibase source repository: see doc.wikimedia.org.

=Prerequisites=

MediaWiki
Since Wikibase is an extension (actually two extensions) to MediaWiki, you'll first need to set up MediaWiki.

Composer
The easiest way to install all dependencies for Wikibase is to use Composer. Here you can find installation instructions for Composer.

=Installation= A basic installation of Wikibase consists of four steps: The following guide will lead you through these steps.
 * 1) Obtain Wikibase
 * 2) Install dependencies
 * 3) Modify LocalSettings.php
 * 4) Run maintenance scripts

Before you begin
Make sure you've set up MediaWiki and installed Composer.

Obtain Wikibase
Check what version of Mediawiki you have by going to yourwiki.com/wiki/Special:Version, and use the version of Wikibase corresponding to your MediaWiki version.

If you have the latest version of Mediawiki, download the latest version of Wikibase (or the version matching your Mediawiki installation) into the  folder of your MediaWiki installation.

Download from Git
Make sure the folder you just downloaded is called  and located in
 * For the latest unstable version of Wikibase:
 * If you have an older version of Mediawiki, to obtain a specific version of Wikibase, specify the name of the branch you want to download. For example, to install Wikibase for Mediawiki version 1.34.x use the Wikibase branch REL1_34:

Download archive

 * Instead of using git, you can download an archive with the latest version of Wikibase or any specific version of Wikibase.
 * Make sure to extract the archive into a new folder called  in the   folder of your MediaWiki installation.

Install dependencies
Thanks to the composer-merge-plugin, you can just add the following code into  at the root of your MediaWiki installation:

Then, from the root of your MediaWiki installation, run:

Then, if composer is available as a binary:

Or, if this last command does not work, try instead:

See the Wikibase README.

Modify LocalSettings.php
At this point from your  you can enable one of these components or both:


 * 1) Wikibase Repository - holds data
 * 2) Wikibase Client - shows data

1. Enable Wikibase Repository only
Important: If you're using master or 1.36 (and above) you need to use extension registration instead. The above code will fail:

These configurations assume that your interwiki prefixes are  and. Adjust as needed.

Note that  wraps all the Wikibase repository configurations. See defaults in Wikibase.default.php.

2. Enable Wikibase Client only
For another lang-wiki client, like Farsi, change the siteGlobalID to:

Important: Similar to above, if you're using 1.36 or master, you need to use this instead:

Note that  wraps all the Wikibase client configurations. See defaults in WikibaseClient.default.php.

3. Enable Wikibase Repository and Wikibase Client
Give a look at the previous sections. In short:

Important: Similar to above:

Run maintenance scripts
Finally, run some maintenance scripts.


 * Run the MediaWiki database update script:


 * Run the script that populates the sites table:

Note: By default, this populates the sites table with Wikimedia's project list. See Manual:Sites table#Managing the sites table for how to list non-WMF projects.

For Wikibase Repository only
Run this php script:

For Wikibase Client only
If you want to run Wikibase Client, you'll also need to run the script that populates the interwiki table:

Warning: This will overwrite existing links in your interwiki table with (by default) Wikipedia values. Don't do this if you have existing inter-language link data you need to keep.

For Wikibase Repository and Wikibase Client
In this case you'll need to run both scripts:

(Again, running populateInterwiki.php will overwrite existing links in your interwiki table with (by default) Wikipedia values.)

Wikibase Repository
To verify that Wikibase Repository has been installed successfully, navigate to the Special:NewItem page in your MediaWiki. You should be able to create your first Item. Enter a label and optional description and aliases and click Create. You should be redirected to the item page.

Wikibase Client
If you've enabled Wikibase Client and everything is correct, you should see an "Add links" link in the languagelinks section in the main page sidebar.

Enable sitelinks
Sitelinks are special links with a site and a title, linking from individual Items to pages on other wikis. In Wikidata these go to other Wikimedia sites such as Wikipedia, Wikisource and Wikivoyage. Among other things, sitelinks allow referencing an Item's property on the linked page in the client wiki, a feature known as Direct access.

1. Configure your sitelink groups
First, consider how to group the client wikis you want to see in your sitelinks area for the Items in your repo wiki.

Define custom groups
In your repo wiki, replace the content of  in   with the groups you would like to see there.

For example, consider the following line in :

This would create three groups in the Item page's sitelinks box:
 * the standard defined  for the global Wikipedia sites
 * two custom wiki groups (here named  and  )

The names defined here will relate to the  field in the   table, as specified below.

In your client wiki, add a similar configuration line with your :

Deactivate the sitelinks feature
If you do not want your installation to make use of sitelinks at all, you can deactivate them by setting the configuration to an empty array:

2. Localize your groups
To show the correct heading for your groups, you must create the page with the desired heading as text.

You can create subpages to set headings for different languages, e.g., create  to create a German heading.

3. Add the wikis to the sites table
In order to add sitelinks to Items in your repo wiki, you must add the client wikis to the sites table. Group names must match the group names you added to your configuration. Following the example above, you would have one or more sites with  and   as text in the   field. You must set both the file path and the page path, and each must include the  placeholder.

Example
To add your wiki (with an id ending with ) to the  group , runL Be sure to do this on the repo wiki and all client wikis so that the "Add links" functionality in the other languages section works correctly.

For further details on how to add sites to the table, please see these instructions.

4. Inform the repo wiki of the other client wiki databases
localClientDatabases: An array of locally accessible client databases, for use by the  script. This setting specifies which wikis to directly push changes to. It must be specified either as an associative array (mapping global site IDs to logical database names) or as a list of databases (if the database names match the site IDs). The default is an empty array, indicating no local client databases.

5. Verify that you can add sitelinks

 * 1) Go to the   page in your repo wiki and try to link an existing Item (field "ID") to one of the sites configured above (field "Site ID") by specifying an existing page on that wiki (field "Sitelink"). If it fails, it should provide a useful error message.
 * 2) On the page you added above, check that Direct access works by referencing a property of the Item in a parser function.

There are very few languages I can set labels for in a new item.
Make sure you installed Extension:UniversalLanguageSelector

There are no sites I can link pages to in an item.
One or more of the following may help:

= References =