PostgreSQL
Contents |
[edit] Prerequisites
MediaWiki with PostgreSQL 8.3 backend must be installed beforehand. The database cluster must have been initialized with UTF-8 encoding. PL/PgSQL must be installed in the database.
When the default client encoding is other than UTF8 in postgresql.conf, MediaWiki needs a patch.
Before setup, the (empty) database schema must exist; this can either be the (default) public schema or a schema named after the login name that MediaWiki uses to access the database. In any case, the tables must be accessible without explicit schema qualification, e.g. by using appropriate default search path in postgresql.conf.
The MediaWiki user does not need to be the owner of the database, but appropriate rights are necessary, e.g. to create/execute PL/PgSQL scripts.
[edit] Installation
Installation should proceed as usual. Before creating any pages, the following statement must be executed against the server (e.g. using psql or PgAdmin):
select max(smw_id) from smw_ids; -- get value alter sequence smw_ids_smw_id_seq restart with x + 1 -- value from select above, add 1
1.4.2 still contains a bug in includes/storage/SMW_SQLStore2.php, apply the following patch:
940c940
< $res = $db->query('(SELECT smw_id, smw_title, smw_sortkey, COUNT(*) as count FROM ' .
---
> $res = $db->query('(SELECT smw_id, smw_title, COUNT(*) as count, smw_sortkey FROM ' .
[edit] PostgreSQL 9 and bytea_output
Beginning with PostgreSQL 9, the output format of the bytea datatype must be set to 'escape'. You do this in your postgresql.conf file:
bytea_output = 'escape' # Semantic MediaWiki (1.5.6) still expects the old 'escape' format
Otherwise the output will default to the new 'hex' format. Semantic properties of type 'text' will be garbled in query results. Instead of seeing text, you will see large numbers such as this: \x506f736974696f6e2077697468207265736f75726365732061747461636865642e.
[edit] Limitations
Currently the PostgreSQL support has only been tested with the login user being the owner of the schema that contains the MediaWiki tables.
[edit] Example installation
(installation notes for installing semanticmediawiki/postgresql from scratch on CentOS 5.2)
In this example apache is running in a OpenVZ partition contained within a XEN 32bit paravirtualized DomU running on the 64bit Dom0 Main Server. The PostgreSQL database server is running on a different host without virtualization.
Please note that CentOS 5.2 does not include PostgreSQL 8.3 by default, use the packages from http://yum.pgsqlrpms.org (and corresponding php-pgsql packages as well).
Here is what needs to be done:
- create a virtual web server on apache
- create a user (e.g. semanticweb.org or whatever your wiki is about) within your postgresql database, having superuser privileges
- ensure that the user can successfully access the database from the webserver by adding it in pg_hba.conf on the database server
- create a schema named like the user (e.g. semanticweb.org) within your database, having user semanticweb.org as owner
- download and unpack the mediawiki software, e.g. http://download.wikimedia.org/mediawiki/1.14/mediawiki-1.14.0rc1.tar.gz
- move the unpacked files to your webserver root, chgrp -R apache *
- chmod g+w config, access http://[your server]/config/index.php
- Verify settings; note that eaccelerator may not be recognized (despite the fact that phpinfo() reports it's installed)
- after successful installation/table creation move LocalSettings.php to the parent directory from config/
- apply the patch to ensure MediaWiki uses UTF8 encoding on the database in includes/db/DatabasePostgres.php
- download and install SemanticMediaWiki according to the INSTALL file
- after "Database installation and upgrade", adjust the sequence in the database (see "Installation" above)
now your installation should work properly.