2011-02-17: This site is still under construction. Sorry for mix of languages. I will try to fix that and get more features online the next days and weeks.

cplewnia.de

Howto: Setup Mozilla Weave Server (Firefox Sync Server)

Introduction

Firefox Sync provides an easy way to synchronise your bookmarks, passwords, preferences, history and tabs with your computers using Firefox or mobile devices using Firefox Mobile (you are able to choose what you want to sync). The data is normally stored in the web to make it accessible from everywhere at any time. As things are now (February 2011) there are two ways to do that. Either you store your data on Mozilla's servers or on your own server. However your data will always be encrypted before storing it on the server using a key (which you should keep in safe custody, because loosing the key means loosing access to your data). I cannot evaluate how safe the encryption is but i guess it is good enough for normal users to entrust their data to Mozilla's servers.

Nevertheless there are cases where you might want to setup your own Weave-Server (e.g. because you want to provide a Weave-Server in a local network or because of your paranoia). Note that it is not possible to store the data on an FTP server. You really need to have a Weave-Server. You can either use the normal Weave-Server, which i will do in this howto, or use the Minimalistic Weave Server. The normal Weave-Server consists of two elements you have to download and install separately: The Weave Sync Server and the Weave Registration Server.

Requirements

While creating this howto i used the following software. However you should be able to work with different versions as long as you match the requirements.

Notice: It is a bit tricky to compile PHP 5.3.5 with MySQL 5.5.8 because some headerfiles of MySQL are moved to new places. PHP therefore cannot find these headerfiles and reports these header files as missing. A dirty but simple workaround is to copy these header files (fortunately only a few files) to the places where PHP expects them to be (PHP tells you were these files should be).

Requirements

  • locale "en_US.UTF-8"
  • PHP build with JSON, UTF8, mbstring, PDO and the PDO driver for the database you like to use for storage and authentification (in this howto the MySQL driver will be used)
  • Apache build with SSL support (optional, but recommended)

Locale

The sync-server makes in /weaveserver-sync/1.0/weave_user/mysql.php on line 83 use of setlocale() (see PHP-Manual: setlocale()):

if (setlocale(LC_CTYPE, "UTF8", "en_US.UTF-8") == false)
{
    error_log("no standard locale available for setlocale");
    throw new Exception("Database Unavailable", 503);
}

PHP itself uses the setlocale()-command of the operating system and as locales can be handled a bit different by each operating system things are getting difficult here.

If you have SSH access to your webserver you should check your locales with:

locale -a

Without SSH access you might like to try executing a system()-command with PHP. Create a PHP file with the following content at a place you are able to access with your webbrowser:

<?php
    system('locale -a');
?>

Access the file with your webbrowser. If it works PHP should show the installed locales.

If "en_US.UTF-8" is listed everything should be fine so far. If it is not listed you need either to install it or to add your preferred (already installed) locale. Installing a locale usually requires SSH access to the machine and depends on the operating system. For example on Debian systems executing the following command will show you a menu where you can select and install missing locales:

dpkg-reconfigure locales

If you have no SSH access try adding an existing locale to the setlocale()-command. For example if you want to add "de_DE.utf8" for German UTF8 locale modify the setlocale()-command in mysql.php on line 83 as following:

if (setlocale(LC_CTYPE, "UTF8", "en_US.UTF-8", "de_DE.utf8") == false)

Notice: If your locale is named slightly different (for example "en_US.utf8" instead of "en_US.UTF-8") this might work as well.

PHP

According to Mozilla Labs PHP 5.1+ should match the PHP requirements. However if you build PHP from source remember to:

  • Compile PHP after you have installed the correct locales. 
  • Enable MySQL (see PHP-Manual: MySQL Installation)
  • Enable PDO (in newer PHP version this is a default setting)
  • Enable JSON (in newer PHP version this is a default setting)
  • Enable PDO-driver for MySQL (see PHP-Manual: PDO drivers)
    In case of MySQL you have to use "--with-pdo-mysql[=DIR]" where DIR is the path to your MySQL installation.
  • Enable support for multi-byte-strings by using "--enable-mbstring".

Verify your (existing) installation

Create a PHP file with the following content at a place you are able to access with your webbrowser:

<?php
   phpinfo();
?>

You should be able to see a section for "mysql", "PDO", "json" and "mbstring". Some sections like "mysql" and "openssl" display the version of their installation. You need to verify that in section "PDO" "mysql" is listed as PDO-driver and that the support for "json" and "mbstring" is set to enabled.

Content

Print | 10.162 clicks | Howto | 20.02.2011 - 18:40:05

Login: