Content Home Index

Setup Web Server and cgi Scripts for Database Synchronization

The synchronization feature is intended to exchange the training data with an external storage on an Apache web server. The necessary cgi scripts written in Perl are located at src/httpd/.
The synchronization uses http/TCP through the WLAN or telco interface.

Structure and Background

The script list.cgi provides the status of the stored databases, upload.cgi stores a database file on the web server and download.cgi delivers a database file from the web server. The authorization is implemented with a password delivered through the url.

The structure of the data directory looks like this:

The following is an example of an virtual Apache server on Mac OS X. On OS X 10.5.6 the web server configuration file is /private/etc/apache2/httpd.conf. In this case, the directory for all karatasi http stuff is /Store/httpd/karatasi/cgi-bin/, replace it as needed.

Listen 8888

<VirtualHost *:8888>
 DocumentRoot /Store/httpd/karatasi/data
 ServerName localhost
 ErrorLog "/private/var/log/apache2/karatasi_error_log"
 CustomLog "/private/var/log/apache2/karatassi_access_log" common
 <IfModule mod_alias.c>
  Alias /karatasi/ /Store/httpd/karatasi/data/
  ScriptAlias /cgi-bin/ /Store/httpd/karatasi/cgi-bin/
 <Directory /Store/httpd/karatasi/data>
  Options Indexes FollowSymLinks Includes +Multiviews
  AllowOverride All
  order deny,allow
  deny from all
  allow from localhost
 <Directory "/Store/httpd/karatasi/cgi-bin">
  AllowOverride None
  Options None
  Order allow,deny
  Allow from all

The cgi-bin directory containing the scripts is /Store/httpd/karatasi/cgi-bin, the data directory is /Store/httpd/karatasi/data/. For karatasi on the iPhone all parameters as server, port, username and password can be configured in the application preferences. Select 'Web Server' as the synchronisation protocol if you are using the cgi scripts.

Setting up the Synchronization

I am using here /Store/httpd/karatasi as the base directory for the virtual web server, replace as needed by your preferred location. I am using OS X 10.5.6, but it should work similar for other versions and other Unix flavors.

1) Download source package

Download the karatasi httpd package that fits to the version of your software from
Unpack it.

2) Change into the source directory of the http support

> cd karatasi-*/src/httpd

3) Edit the script if you want to change the web server directory or are not using OS X

Change these variables:

4) Run the configuration script

The script expects the username and the user password as parameters. This is the username and password that you enter at the karatasi settings screen (application preferences). It doesn't have to be the same as the Unix user name, the password should *never* be your Unix password.
For example with the username 'mathias' and the password '123456'

> sudo ./ mathias 123456

5) Enter the configuration data into the karatasi settings

On the iPhone go to the application preferences.
Set the host name, port (default 8888), user name and user password.

6) Configure any firewalls to accept connections from your device

7) The setup is finished, enjoy!