Fuseki SPARQL server

From /

For the purpose of this tutorial I will use the database name test

Run Fuseki as a systemd service

As root got

cd /usr/local/src

Download & untar

tar xfvz apache-jena-fuseki-3.15.0.tar.gz
cd apache-jena-fuseki-3.15.0

Fuseki File Layout

I will follow the Filesystem layout suggested by the official documentation for [1] for running Fuseki as a service

Environment Variable 	Default Setting
FUSEKI_HOME 	        /usr/share/fuseki
FUSEKI_BASE 	        /etc/fuseki
  • FUSEKI_HOME(Distribution area) – a is essentially the fuseki-server binary and a few helper scripts
  • FUSEKI_BASE(Runtime area) – is a directory that contains the configuration, dbs, logs - which should be backup and not changed with updates of the Fuseki binaries.

So let's go ahead and create those directories and move the corresponding files to the right dir

mkdir /usr/share/fuseki
mkdir /etc/fuseki
cp -r {fuseki,fuseki-server,fuseki-server.bat,fuseki-server.jar,fuseki.war,bin,webapp} /usr/share/fuseki/
cp -r run/* /etc/fuseki/

cp /etc/fuseki/

And we can make a test run by running:


And checking the if the server is up by visiting http://localhost:3030/index.html

Service file

Inside the untared dir /usr/local/src/apache-jena-fuseki-3.15.0 you can find the file fuseki.service

This file should be copied to /etc/system.d/system and edited in order to run Fuseki as a service. The file itself is quite self explanatory. I have added a few changes, mainly in relation to logging.

cp fuseki.service /etc/systemd/system
vi /etc/systemd/system/fuseki.service

# Edit environment variables to match your installation
# Edit the line below to adjust the amount of memory allocated to Fuseki
# Edit to match your installation
# Run as user "fuseki"
# Java processes exit with status 143 when terminated by SIGTERM, this
# should be considered a successful shutdown
### By default, the service logs to journalctl only.
### This logs to syslog. If, e.g., rsyslogd is used, you can provide a file
### /etc/rsyslog.d/fuseki.conf, consisting of the following two lines (uncommented)
#if $programname == 'fuseki' then /var/log/fuseki/stderrout.log
#if $programname == 'fuseki' then stop


Create logs dir:

mkdir /var/log/

Enable and run the service:

systemctl enable fuseki
systemctl start fuseki

Check it's status

systemctl status fuseki

And again check its web UI at http://localhost:3030

  • you try to create a db a make and perform and INSERT statement, which be stored in /etc/fuseki/databases/databasename/


Fuseki security settings are defined in file /etc/fuseki/shiro.ini [2]

Here I can change the default admin password


  • ensure the admin password is something strong

And also the rights to Fuseki Administative HTTP protocol[3] and access to the existing DBs.

I will allow the db test to be queried by anyone but only updated by the locahost, so that the SMW can write to it, but requests coming from outside cannot update it, but can query, with:

/test/query  = anon
/test/update  = localhostFilter

Full shiro.ini

# Licensed under the terms of

ssl.enabled = false 

iniRealm.credentialsMatcher = $plainMatcher


# Implicitly adds "iniRealm =  org.apache.shiro.realm.text.IniRealm"



# All admin operations have URL paths starting /$/ to avoid clashes with dataset names and this prefix is reserved for the Fuseki control functions.
/$/status = anon
/$/ping   = anon
/$/stats/**  = anon

# test db
/test/query  = anon
/test/update  = localhostFilter

# everything else only accessible to localhost 
/** = localhostFilter

To test we should restart fuseki systemctl restart fuseki and run a few requests, from both localhost and external host:

A query coming from both local and remote hosts, where both should succeed:

curl http://localhost:3030/test/query -X POST --data '*%0A%7B%0A+%3Fs+foaf%3Aname+%22Test%22%40en+.%0A%7D' -H 'Accept: application/sparql-results+json,*/*;q=0.9'
curl -X POST --data '*%0A%7B%0A+%3Fs+foaf%3Aname+%22Test%22%40en+.%0A%7D' -H 'Accept: application/sparql-results+json,*/*;q=0.9'

An update, which should succeed only when coming from localhost, and fail when coming from remote

curl http://localhost:3030/test -X POST --data '' -H 'Accept: text/plain,*/*;q=0.9'
curl -X POST --data '' -H 'Accept: text/plain,*/*;q=0.9'


Apache Fuseki Logging is performed via SLF4J over Apache Log4J2.

The Fuseki engine looks for the log4j2 configuration, in different locations, but I will stick with:

  • file in the directory defined by FUSEKI_BASE: /etc/fuseki was in previous steps copied to /etc/fuseki/ and includes the default logging settings.


It is possible to send a POST request for Fuseki to create a backup of a database, with

curl http://localhost:3030/$/backup/test -X POST -H 'Accept: application/sparql-results+json,*/*;q=0.9' 

Here the test db will be backup up, and stored in /etc/fuseki/backups under a gzip-compressed N-Quads file test_2020-05-23_14-42-41.nq.gz

Which, when decompressed, will show a contained list of triples which makes up the db:

gzip -d test_2020-05-23_14-42-41.nq.gz
cat test_2020-05-23_14-42-41.nq
<> <> "Zexix"@en .
<> <> "Zyz"@en .
<> <> "Ouoaoo"@en .

/$/backups-list will show the list of existing backups:

curl http://localhost:3030/$/backups-list -X POST -H 'Accept: application/sparql-results+json,*/*;q=0.9' 
  "backups" : [ 
      "test_2020-05-23_14-42-41.nq" ,


... more about "Fuseki SPARQL server"
Code_Notes +
Date"Date" is a type and predefined property provided by Semantic MediaWiki to represent date values.
2020 +