My favorites | Sign in
Logo
                
Search
for
Updated Dec 12 (6 days ago) by arndtn
Labels: Phase-Deploy
UsingOntoWikiWithVirtuoso  
Tutorial on Setting up OntoWiki with Virtuoso

Using OntoWiki with Virtuoso

This guide explains the necessary steps to use OntoWiki with OpenLink Virtuoso.

Overview

This is the basic procedure. For details see below.

  1. Check out the OntoWiki source code (trunk/ontowiki/src) from Google Code.
  2. Download Virtuoso Open-Source Edition and compile it according to the instructions for your operating system.
  3. Install and configure Virtuoso.
  4. Set up ODBC and make sure, PHP can connect to Virtuoso via ODBC.
  5. Set up OntoWiki to be used with Vrituoso.

Compiling Virtuoso

For some OS, e.g. Windows, binaries exist. If you have to compile it, it is recommended to give a <prefix>, which will be the path where Virtuoso will be installed.

Ubuntu recommendation: use ./configure --prefix=/opt/virtuoso. Virtuoso also comes along with a good README with further instructions. Ubuntu Tipp: configuring with the libreadline library allows for better characters passing to isql command line client '--with-readline=path/to/libreadline' (use apt-get install libreadline5-dev and '--with-readline=/usr/lib/libreadline.so'). Also, if you want to activate virtuosos php ability, e.g. for the vad package use --with-php5=/usr/bin/php5.

sudo ./configure --prefix=/opt/virtuoso-opensource-version --with-readline=/usr/lib/libreadline.so --with-php5=/usr/bin/php5

Note for Debian/Ubuntu: You can download a deb-packgage here: http://docs.ontowiki.net/virtuoso/ (nethertheless, you have to configure the DirsAllowed variable)

Compiling Virtuoso requires the following build tools be installed.

Package Version From
autoconf 2.57 http://www.gnu.org/software/autoconf/
automake 1.7 http://www.gnu.org/software/automake/
libtool 1.5 http://www.gnu.org/software/libtool/
flex 2.5.33 http://flex.sourceforge.net/
bison 2.3 http://www.gnu.org/software/bison/
gperf 2.7.2 http://www.gnu.org/software/gperf/
gawk 3.1.1 http://www.gnu.org/software/gawk/
m4 1.4.1 http://www.gnu.org/software/m4/
make 3.79.1 http://www.gnu.org/software/make/
OpenSSL 0.9.7 http://www.openssl.org/

Ubuntu: apt-get install autoconf automake libtool flex bison gperf gawk m4 make openssl libssl-dev

Having these tools, compiling and installing Virtuoso is just a matter of configure/make/make install.

Configuring Virtuoso

Virtuoso keeps all the files for a database in a folder along with a configuration file. An example configuration file which we will use as a base for our configuration is provided with the default database. To create a Virtuoso database for OntoWiki perform the following steps:

  1. Create a folder named "ontowiki" under <prefix>/var/lib/virtuoso/.
  2. Copy the file <prefix>/var/lib/virtuoso/db/virtuoso.ini to <prefix>/var/lib/virtuoso/ontowiki/virtuoso.ini
  3. Open <prefix>/var/lib/virtuoso/ontowiki/virtuoso.ini in a text editor
  4. Find the option "DirsAllowed", it is a comma-separated list of dirs from which Virtuoso is allowed to open files. Add your PHP's temp directory (usually /tmp) and your OntoWiki directory under your webroot.

Setting up ODBC

Database connection to Virtuoso happens through ODBC. ODBC is configured by two files, odbc.ini and odbcinst.ini. On Linux systems they can be found under /etc, on Mac OS X systems under /Library/ODBC. In case they don't exist, create them.

  1. Add the following lines to the odbcinst.ini file:
  2. [virtuoso-odbc]
    Driver = <prefix>/lib/virtodbc.so
  3. Add the following lines to the odbc.ini file:
  4. [ODBC Data Sources]
    VOS = Virtuoso
    
    [VOS]
    Driver = virtuoso-odbc
    Description = Virtuoso Open-Source Edition
    ServerName = localhost:1111

Now make sure, PHP can connect to Virtuoso via ODBC. On some Linux systems you may have to install the ODBC package for PHP (php5-odbc). To test the connection, create a file called odbctest.php in you webroot with the following PHP code in it:

<?php
$conn   = odbc_connect('VOS', 'dba', 'dba');
$query  = 'SELECT DISTINCT ?g WHERE {GRAPH ?g {?s ?p ?o.}}';
$result = odbc_exec($conn, 'CALL DB.DBA.SPARQL_EVAL(\'' . $query . '\', NULL, 0)');
?>
<ul>
<?php while (odbc_fetch_row($result)): ?>
    <li><?php echo odbc_result($result, 1) ?></li>
<?php endwhile; ?>
</ul>

Execute it by clicking on this link: http://localhost/odbctest.php http://localhost/odbctest.php. You should see a list of graphs stored in your Virtuoso RDF store. On a vanilla Virtuoso installation this list should include the following two graphs:

If you see this list and no error messages along the way, go ahead configuring OntoWiki.

Configuring OntoWiki

Perform the following steps to set up OntoWiki:

  1. Copy config.ini-dist to config.ini and open it in a text editor
  2. Under [private], set the following options:
  3. store.backend = virtuoso
    store.virtuoso.dsn = VOS
    store.virtuoso.username = dba
    store.virtuoso.password = dba
  4. Optional 1: to enable OntoWiki's debug mode, add the line debug = yes
  5. Optional 2: If you didn't change any other config option, create the following directories relative to your OntoWiki installation and make them writable to the web-server user.
  6. Optional 3: For the Linked Data plug-in to work, copy the htaccess-dist file to .htaccess make sure your Apache's mod_rewrite module is installed and AllowOverwrite is set to All for your OntoWiki directory in your httpd.conf.

FAQ

Platform-specific Notes

GNU/Linux

To start Virtuoso, switch to <prefix>/bin and run:

./virtuoso-t -f -c /opt/virtuoso/var/lib/virtuoso/ontowiki/virtuoso.ini

(Virtuoso runs in foreground using the created OntoWiki specific configuration file.)

Cave: Run Virtuoso with enough rights. When importing knowledge bases from file, they are first copied to tmp. Virtuoso needs a sufficiently high user like root or www-data to read it (besides adding the tmp dir to DirsAllowed). Otherwise you will get the error:

Error importing knowledge base: Graph '<http://inserttesst.org>' could not be imported: Error importing statements: SQL Error: [unixODBC][OpenLink][Virtuoso iODBC Driver][Virtuoso Server]FA012: Can't open file '/tmp/phpWH20k0', error (13) : Permission denied (37000) CALL DB.DBA.RDF_LOAD_RDFXML(FILE_TO_STRING_OUTPUT('/tmp/phpWH20k0'), '', 'http://inserttesst.org')

Debian GNU/Linux

If you install Virtuoso from the .deb-Package you have to change in '/etc/init.d/virtuoso-opensource' the line

DBBASE=/var/lib/virtuoso/db

to

DBBASE=/var/lib/virtuoso/ontowiki

while virtuoso is not running.

Mac OS X

To auto-start Virtuoso on Mac OS X 10.5 use a config file for the launchd service. It should be placed under /Library/LaunchDaemons. The following is an example file, replace the paths with your settings where necessary.

macbook-pro:~ norman$ cat ~/Library/LaunchDaemons/com.openlinksw.virtuoso.plist 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>UserName</key>
	<string>root</string>
	<key>GroupName</key>
	<string>wheel</string>
	<key>RunAtLoad</key>
	<true/>
	<key>Label</key>
	<string>com.openlinksw.virtuoso</string>
	<key>OnDemand</key>
	<false/>
	<key>ProgramArguments</key>
	<array>
		<string>/usr/local/bin/virtuoso-t</string>
		<string>-f</string>
		<string>-c</string>
		<string>/usr/local/var/lib/virtuoso/ontowiki/virtuoso.ini</string>
	</array>
</dict>
</plist>

Windows

Follow these instructions in order to set up Virtuoso as an ODBC data source on Windows.


Comment by RavenArkadon, Aug 12, 2009

>> SQL Error: unixODBCOpenLinkiODBC DriverServerFA011: Access to /var/www/ontowiki/libraries/Erfurt/include/SysOntLocal?.rdf is denied due to access control in ini file (37000) Solution: do Configuring Virtuoso Step 4

It seems that this file is not copied to /tmp first, so the path /var/www/ontowiki/libraries/Erfurt/include/ needs to be added to DirsAllowed? too. (I got the error despite having /tmp specified).

Comment by fabrizio...@alice.it, Sep 29, 2009

I met the error "access to %file% is denied due to access control in ini file (42000)" while trying to upload a file for creating a new knowledge base.

There is a bug in \libraries\Erfurt\Store\Adapter\Virtuoso.php at line 1091, since, at least in Windows, the slash "\" characters in the file name are not escaped and Virtuoso cannot recognize the correct path, giving such error. The solution id to change the line 1091 in virtuoso.php with:

str_replace("\\","\\\\",$file),

Hope this help, because it made me crazy :S


Sign in to add a comment
Hosted by Google Code