Help:Installation 1.5.1

This page describes how to install Semantic MediaWiki 1.5.1 after having downloaded it (see the bottom of this page for other versions). Installation and upgrade notes change from version to version: the file INSTALL shipped with SMW contains instructions for the particular version you may have downloaded.

To upgrade a wiki running an older version of SMW, please make sure to have read the relevant section before starting the upgrade.

For installing SMW, please check the exact requirements and follow the instructions carefully. The installation does no irreversible changes to your MediaWiki database (it just adds some tables that can be deleted again). However, there is currently no automated process to remove annotations from articles texts in the case that Semantic MediaWiki is to be uninstalled again, but one could achieve this with some script that eliminates annotations on editing.

Disclaimer
Make sure you understand the legal disclaimer in the file COPYING.

Requirements

 * MediaWiki 1.11.* or greater (tested on 1.16.0 to 1.17alpha (r63248)).
 * PHP 5.* or greater installed and working
 * MySQL >= 4.0.14 (version required by MediaWiki) or PostgreSQL >= 8.3 (note that support for the latter is still preliminary and requires some extra steps, see PostgreSQL for details)

Notes:
 * SMW uses the PHP mb_* multibyte functions such as mb_strpos in the php_mbstring.dll extension. This is standard but not enabled by default on some distributions of PHP. See the PHP manual for details.
 * For installation and upgrade, SMW needs the rights to create new tables (CREATE) and to alter tables (ALTER TABLE). Both can be removed again after SMW was set up. The script SMW_setup.php can use the DB credentials from AdminSettings.php for this purpose, avoiding the need of extra rights for the wiki DB user.
 * SMW creates and alters temporary tables for certain semantic queries. To do this, your wikidb user must have privileges for CREATE TEMPORARY TABLES. If this is not desired, the SMW features which require this right can be disabled by adding the following to Localsettings.php:

$smwgQSubcategoryDepth=0; $smwgQPropertyDepth=0; $smwgQFeatures       = SMW_ANY_QUERY & ~SMW_DISJUNCTION_QUERY; $smwgQConceptFeatures = SMW_ANY_QUERY & ~SMW_DISJUNCTION_QUERY & ~SMW_CONCEPT_QUERY;

Installation
If you upgrade an existing installation of Semantic MediaWiki, also read the remarks in the section Upgrading existing installations below! Installing SMW basically requires three (or four) easy steps:

'''(1) Copy files. ''' Extract the downloaded archive, or check out the current files from SVN to obtain the directory "SemanticMediaWiki" that contains all relevant files. Copy this directory to "[wikipath]/extensions/" (or extract/download it to this place). We abbreviate "[wikipath]/extensions/SemanticMediaWiki" as "[SMW_path]" below.

'(2) [optional]'' Adjust namespaces. ''' If you did not make any change the your wiki's namespaces, you can skip this step. If you have defined your own custom namespaces, you have to set the parameter $smwgNamespaceIndex before including SemanticMediaWiki.php. Semantic MediaWiki uses ten additional namespace indexes, in the range from 100 to 109. Note, 100 and 101 are only needed if $smwgSMWBetaCompatible is set. 106 and 107 are reserved for the SemanticForms extension and not used by SMW. See the documentation within SMW_Settings.php for details. If you add namespaces after installing SMW, then you have to assign them to higher numbers than those used by Semantic MediaWiki.

Note: Semantic MediaWiki only evaluates semantic annotations in some namespaces. For example, by default it ignores semantic annotations in talk pages. If you want to change the namespaces with annotations (likely if you have added your own custom namespaces), then you have to change the array variable $smwgNamespacesWithSemanticLinks in SMW_Settings.php.

'''(3) Enable the extension. ''' Insert the following two lines into the file "[wikipath]/LocalSettings.php":

include_once("$IP/extensions/SemanticMediaWiki/SemanticMediaWiki.php"); enableSemantics('example.org');

where example.org should be replaced by your server's name (or IP address). This string is only used as a globally unique name for identifying the wiki's exported data on the Semantic Web, and a valid server name works very well for that purpose. There is no need to worry if a wiki has more than one server name – just pick one.

'''(4) Setup database. ''' In your wiki, log in as a user with admin status and go to the page "Special:SMWAdmin" to do the final setup steps. Two steps are needed: at first, trigger the database setup ("Database installation and upgrade"). Afterwards, activate the automatic data update ("Data repair and upgrade"). Note that the first step requires permissions to alter/create database tables, as explained in the above note. The second step takes some time; go to Special:SMWAdmin to follow its progress. SMW can be used before this completes, but will not have access to all data yet (e.g. page categories).

Testing your Installation
If you are uncertain that everything went well, you can do some testing steps to check if SMW is set up properly.

Go to the Special:Version page. You should see Semantic MediaWiki (version nn) listed as a Parser Hook there.

Create a regular wiki page named "TestSMW", and in it enter the wiki text

Property test: testproperty::Dummypage

When previewing the page before saving, you should see a Factbox at the bottom of the article that shows your input. After saving the page, click on the link "Browse properties" in the page's toolbox. This view should show Testproperty with value Dummypage.

Running SMW on older versions of MediaWiki
In general, it is not recommended to run older versions of MediaWiki, since every new release brings also security fixes. If your site is still running on PHP4, SMW is not supported. It would hardly be possible to backport the code to the old PHP version. If you have PHP5 but an older MediaWiki version, additional patches/modifications might be needed. Download an older release of SMW and have a look at the included INSTALL instructions to find out whether other changes are recommended therein.

Upgrading existing installations
Installations of SMW 1.5.0 can be upgraded by just replacing the files, but it must be noted that not all SMW extensions may already be available in versions compatible to SMW 1.5.1. Others are and should be updated together with SMW, such as Semantic Maps which now requires version 0.6. If problems occur, it is possible to go back to 1.5.0 by simply using the old files, waiting with the upgrade until the relevant extensions provide updates.

It is suggested to change the inclusion of SMW in LocalSettings.php to the following as described in the installation instructions above:

include_once("$IP/extensions/SemanticMediaWiki/SemanticMediaWiki.php");

Including SMW_Settings.php as in earlier versions will continue to work, but may be disabled in some future version.

Existing SMW 1.4.* installations and all SMW installations that already use the default store (SMWSQLStore2) can basically follow the above installation steps. The latter covers all sites with SMW 1.2 to 1.3 that do not use a special setting to switch back to the old store ("SMWSQLStore" or "SMWRAPStore"). Older versions of SMW can be upgrade in a similar fashion, but must ensure that they do not depend on now peculiarities of the old version. Please read the upgrade instructions for SMW version 1.2 and 1.3 for details. Moreover, SMW 1.5.0 finally removed all backwards compatibility to SMW beta versions below SMW 1.0. If your wiki still uses the setting $smwgSMWBetaCompatible=true</tt> then you should not upgrade until you find that disabling this setting works properly and without complications.

There are two changes in SMW functionality that may affect some sites that used earlier versions. Additional steps are required if the wiki uses n-ary (multivalued) properties or properties of type Geographic coordinate and the required upgrade steps are described in separate sections below.

Directly after enabling SMW 1.5.1, it could potentially happen that the site shows SQL errors due to background jobs trying to access the new DB structure even before you initialised it. This can even block you from reaching SMWAdmin. In this case, either use the script SMW_setup.php from the command-line, or access your database and delete all entries in the table "job". After this, no errors should show up while accessing the special page for initialisation.

When upgrading from SMW 1.4.* or older, extensions of SMW (e.g. Semantic Forms) need to be updated to a version that is compatible with SMW 1.5.1. See your extension's homepage for details. If used, it is suggested to update to a compatible version of SemanticResultFormats (SRF). The formats have been migrated to this extension package and are enabled there by default after installation.

Geographic coordinates
The datatype Geographic coordinate has been moved from SMW to the Semantic Maps extension. Wikis that use this type should install Semantic Maps version 0.6 or above. No other changes are needed, but it is recommended to install Semantic Maps before upgrading SMW so as to avoid problems at any time. The move has been done to concentrate geo-related features in one extension for better maintenance and ease of use.

N-ary (multivalued) properties
The way how these properties are declared on their property pages has changed since SMW 1.4.3, and it is necessary to change the pages of all such properties to use them again as before. Until SMW 1.4.*, such properties were declared by type declarations as in the following example:

has type::Page; Number; String

In this case, a property with three fields of the specified types was declared. You can use the inline query to obtain a list of all properties in your wiki that are of this form at all. In SMW 1.5.1, two property assignments must be made on the property page instead:

has type::Record has fields::Page; Number; String

In other words, all "n-ary" properties are now of the new datatype Record, and the information about their fields is stated independently. This change allowed for many improvements in SMW, and makes it possible to create new (better) extensions for supporting compound property values in the future.

To upgrade, first install the new version of SMW, then use the above inline query to efficiently find all properties that need to be changed. After updating the pages as required, all values should be accessible as before (possibly some repair jobs need to finish before this is really the case; check your job queue). If you change the pages before the upgrade to SMW 1.5.1, then it will be necessary to start a repair cycle of SMW to ensure that all affected page are indeed updated.

Changed configuration options
Some configuration options (used in LocalSettings.php) have changed since SMW 1.0. All settings are documented in detail in the file SMW_Settings.php</tt>. The following list gives the version in which a setting was first introduced, so it can be ignored if you already run this version or a more recent one.


 * [1.4] Up to version 1.4, the default for value for the setting $smwgQComparators</tt> was '<|>|!'</tt>. It now has changed to '<|>|!|~'</tt> so the "like" comparator ~</tt> is enabled by default.
 * [1.4] Version 1.4 still supported a setting $smwgSMWBetaCompatible</tt> to enable the old query syntax and the Relation namespace. This backwards compatibility has now been dropped and the setting is no longer used. Please update your wiki to not use the outdated (and now undocumented) features.
 * [1.3] Since SMW 1.3, the Factbox is hidden by default and will only appear in page previews. As a compensation, the toolbox (usually on the left below the search field) shows a link to Special:Browse. To use the display behaviour of the Factbox as it was before SMW 1.3, set $smwgShowFactbox = SMW_FACTBOX_NONEMPTY;</tt> The new link and the Factbox during editing can also be configured; see SMW_Settings.php</tt> for details.
 * [1.2.1] SMW will no longer support nested link syntax in property values by default, since this was known to cause problems. To re-enable this, set $smwgLinksInValues = true;</tt>
 * [1.2] If your wiki uses  </tt> syntax or the Relation:</tt> namespace, you may want to set $smwgSMWBetaCompatible = true;</tt> before the line including SemanticMediaWiki.php (formerly SMW_Settings.php) in LocalSettings.php. Consider changing  </tt> to #ask</tt> to be able to drop SMW beta compatibility.
 * [1.2] If you had a setting $smwgQDisjunctionSupport = false;</tt> then you now need the following settings in your <tt>LocalSettings.php</tt>:

$smwgQFeatures       = SMW_ANY_QUERY & ~SMW_DISJUNCTION_QUERY; $smwgQConceptFeatures = SMW_ANY_QUERY & ~SMW_DISJUNCTION_QUERY & ~SMW_CONCEPT_QUERY;


 * [1.0] <tt>$smwgQEqualitySupport</tt> is one of <tt>SMW_EQ_NONE, SMW_EQ_SOME, SMW_EQ_FULL</tt> (it was <tt>true</tt> or <tt>false</tt> until SMW 1.0 RC1-3).
 * [1.0] <tt>$smwgQDefaultNamespaces</tt> is now <tt>NULL</tt> by default, so that all namespaces are queried. The default in SMW RC 1-3 was '<tt>array(NS_MAIN, NS_IMAGE)</tt>'.
 * [1.0] <tt>$smwgQDefaultLinking</tt> now defaults to '<tt>all</tt>' such that all query results are linked. This is not a performance issue any more. The default until SMW RC 1-3 was '<tt>subject</tt>'.

If you currently set any of these parameters in your <tt>LocalSettings.php</tt>, you need to update this file. Please see <tt>SMW_Settings.php</tt> for more documentation on the available parameters.