Weave
howto install a weave-server for firefox's built-in sync functionallity
Inhaltsverzeichnis
requirements
- apache2, configured with ssl and a valid certificate.
- php-5.1 with json, utf8 and pdo support
- mysql-5
download
install
get the source
mkdir /var/www/mydomain.de/weave cd /var/www/mydomain.de/weave wget http://hg.mozilla.org/services/sync-server/archive/tip.tar.gz mv tip.tar.gz sync-server.tar.gz wget http://hg.mozilla.org/services/reg-server/archive/tip.tar.gz mv tip.tar.gz reg-server.tar.gz tar -xvzf sync-server.tar.gz tar -xvzf reg-server.tar.gz mv sync-server-bc2f6caf8fc8 sync-server mv reg-server-2a73b7376e2c/ reg-server
create the apache vhost
# weave server (firefox build-in sync) <VirtualHost *:80> ServerName weave.mydomain.de # SSL only!!! Redirect / https://weave.mydomain.de </VirtualHost> <VirtualHost *:443> ServerName weave.mydomain.de ServerAdmin webmaster@mydomain.de DocumentRoot /var/www/mydomain.de/weave Alias /1.1 /var/www/mydomain.de/weave/sync-server/1.1/index.php Alias /1.0 /var/www/mydomain.de/weave/sync-server/1.1/index.php Alias /user/1.0 /var/www/mydomain.de/weave/reg-server/1.0/index.php Alias /user/1 /var/www/mydomain.de/weave/reg-server/1.0/index.php Alias /misc/1.0/captcha_html /var/www/mydomain.de/weave/reg-server/1.0/captcha.php Alias /misc/1/captcha_html /var/www/mydomain.de/weave/reg-server/1.0/captcha.php Alias /weave-registration-static /var/www/mydomain.de/weave/reg-server/1.0/static Alias /weave-password-reset /var/www/mydomain.de/weave/reg-server/1.0/forgot_password.php DirectoryIndex index.php index.html index.htm ServerSignature Off <Directory "/var/www/mydomain.de/weave/"> Options Indexes FollowSymLinks AllowOverride none Order allow,deny Allow from all </Directory> SSLEngine On SSLCertificateFile /etc/apache2/ssl/_asterisk_.mydomain.de.crt SSLCertificateKeyFile /etc/apache2/ssl/_asterisk_.mydomain.de.key </VirtualHost>
set up mysql
create database:
create database weave;
create tables:
CREATE TABLE `collections` ( `userid` int(11) NOT NULL, `collectionid` smallint(6) NOT NULL, `name` varchar(32) NOT NULL, PRIMARY KEY (`userid`,`collectionid`), KEY `nameindex` (`userid`,`name`) ) ENGINE=InnoDB Create Table: CREATE TABLE `wbo` ( `username` int(11) NOT NULL, `collection` smallint(6) NOT NULL DEFAULT '0', `id` varbinary(64) NOT NULL DEFAULT '', `parentid` varbinary(64) DEFAULT NULL, `predecessorid` varbinary(64) DEFAULT NULL, `sortindex` int(11) DEFAULT NULL, `modified` bigint(20) DEFAULT NULL, `payload` longtext, `payload_size` int(11) DEFAULT NULL, `ttl` int(11) DEFAULT '2100000000', PRIMARY KEY (`username`,`collection`,`id`), KEY `modified` (`username`,`collection`,`modified`), KEY `ttl_idx` (`ttl`), KEY `parentindex` (`username`,`collection`,`parentid`), KEY `weightindex` (`username`,`collection`,`sortindex`), KEY `predecessorindex` (`username`,`collection`,`predecessorid`), KEY `size_index` (`username`,`payload_size`) ) ENGINE=InnoDB DEFAULT CREATE TABLE `users` ( id int(11) NOT NULL PRIMARY KEY auto_increment, username varbinary(32) NOT NULL, password_hash varbinary(128) default NULL, email varbinary(64) default NULL, status tinyint(4) default '1', alert text, reset varchar(32), reset_expiration datetime ) ENGINE=InnoDB;
create user:
grant all privileges on weave.* to weave@localhost identified by 'mySecurePW';
configure sync-server for mysql
cd /var/www/mydomain.de/weave/sync-server/1.1/ cp -a default_constants.php.dist default_constants.php
now edit this file to meet your sql-db
vi default_constants.php
configure reg-server for mysql
cd ../../reg-server/1.0/ cp -a weave_user_constants.php.dist weave_user_constants.php
now edit this file to meet your sql-db:
vi weave_user_constants.php
bugs
some bugs...
locale bug
list your locale's installed on your system:
locale -a
if you can not find en_US.UTF8 in that list you will have to edit the file /var/www/mydomain.de/weave/sync-server/1.0/weave_user/mysql.php in line 84:
//if (setlocale(LC_CTYPE, "UTF8", "en_US.UTF-8") == false) if (setlocale(LC_CTYPE, "UTF8", "de_DE.UTF-8") == false)
comment out the line and insert an utf-8 locale installed on your system.
in my case this was 'de_DE.UTF-8'
path bug
there is a path problem in regservers index.
so i edited /var/www/mydomain.de/weave/reg-server/1.0/index.php
in my case the corresponding code starts @ line 49
AND
/var/www/mydomain.de/weave/sync-server/1.1/index.php
in my case the corresponding code starts @ line 49
if (!empty($_SERVER['PATH_INFO'])) $path = $_SERVER['PATH_INFO']; else if (!empty($_SERVER['ORIG_PATH_INFO'])) $path = $_SERVER['ORIG_PATH_INFO']; else if (!empty($_SERVER['REQUEST_URI'])) $path = $_SERVER['REQUEST_URI']; else report_problem("No path found", 404);
i added these 2 lines:
else if (!empty($_SERVER['REQUEST_URI'])) $path = $_SERVER['REQUEST_URI'];
hash error
i've run into problems because my php installation sadly did not support the function 'hash()'
so i replaced it by using mhash()-function which seems to work well, too
I did this because it's a system behind firewall!! DO NOT DO THIS ON WORLD-REACHABLE OR PRODUCTION HOSTS!!! |
so if you see errors in your apache error-log while running the test-script like this:
[error] [client 10.0.1.6] PHP Fatal error: Call to undefined function hash() in /srv/www/weave/reg-server/1.0/weave_user/mysql.php on line 97
edit that line to:
$ssha = "{SSHA-256}" . base64_encode( mhash(MHASH_SHA256, $password . $salt, true) . $salt);
search for other occurences of: hash('sha256'
i found one in line 316 and changed it to:
$sha_hash = mhash(MHASH_SHA256, $p_array[0].WEAVE_SHA_SALT.$p_array[1]);
after grep-ing the whole directory tree recursive for the hash()-function
i found 2 files dealing with it and for every file i found 2 calls to hash()-funtion:
- reg-server/1.0/weave_user/mysql.php (change 2 lines)
- sync-server/1.1/weave_user/mysql.php (change 2 lines)
ONLY DO THESE CHANGES IF YOU HAVE TROUBLE WITH THE hash()-FUNCTION Please re-read this section (hash error) carefully!!!!! |
test installation
TODO: test the server |
1st to test is if registration works.
be sure you have php-cli installed...
walk to /var/www/mydomain.de/weave/reg-server/tests/
edit test_1.0.php and edit the server-setting to meet you apache-config
the default value is 'https://localhost' which didn't work for me:
$server = 'https://weave.mydomain.de';
now run:
php test_1.0.php
if the test runs without errors, configure your browser to sync
with your brand new weave-sync-server!
have fun! ;-)
see also
- official docu for reg-server: https://wiki.mozilla.org/Labs/Weave/User/1.0/Setup
- official docu for sync-server: https://wiki.mozilla.org/Labs/Weave/Sync/1.0/Setup