Services/Sync/Server/Archived/0.3/Setup

From MozillaWiki
Jump to navigation Jump to search

Pre-Setup Considerations

It is strongly recommended that the Weave Server be set up under https, especially if you are planning to use Apache basic authorization for access control.

The Weave server doesn't handle authentication, which can be done through any method you choose. Nor does it require authentication (unless the USER_MATCH variables are set, in whch case the server requires HTTP_AUTH_USER to be passed through).

The Weave Server requires PHP with PDO and JSON support installed. This should be the case if you are running PHP 5.1+.

Setting up the Weave Server (Sqlite backend)

1) Unzip the weave_server.zip directory into the location you plan to serve the files from.

2) Create your directory for the stores. Make sure that the folder is writeable by the apache user, and add it to open_basedir in your php.ini file.

3) Edit your apache conf files to add the following:

Alias /weave/0.3 <full path to weave directory>/index.php
SetEnv WEAVE_STORAGE_TYPE sqlite
SetEnv WEAVE_SQLITE_DIRECTORY <path to stores directory>

Setting up the Weave Server (Mysql backend)

1) Unzip the weave_server.zip directory into the location you plan to serve the files from.

2) Create the mysql database. Add the following table:

create table wbo
(
 username varchar(32),
 collection varchar(64),
 id varchar(64),
 parentid varchar(64),
 modified float,
 encoding varchar(16),
 payload text,
 primary key(username, collection, id),
 index parentindex(username, collection, parentid),
 index modified(username, collection, modified)
) engine=InnoDB;

3) Edit your apache conf files to add the following:

Alias /weave/0.3 <full path to weave directory>/index.php
SetEnv WEAVE_STORAGE_TYPE mysql
SetEnv WEAVE_MYSQL_HOST <db host>
SetEnv WEAVE_MYSQL_DB <db name>
SetEnv WEAVE_MYSQL_USER <db username>
SetEnv WEAVE_MYSQL_PASS <db password>

Optional Apache Parameters

SetEnv WEAVE_USER_MATCH_READ 1

Requires the http-authenticated user to match the name of the user in the path in order to read from the store (recommended)

SetEnv WEAVE_USER_MATCH_WRITE 1

Requires the http-authenticated user to match the name of the user in the path in order to write to the store (recommended)

Testing the Weave Server

The load_data.pl script will run a series of tests against your server, creating, modifying, selecting from and deleting a collection. Make sure to change the three parameters at the top before running it. Also, the script requires the libwww-perl module.

Creating Accounts

If WEAVE_AUTO_CREATE_USER is set, then a user account will be created on the first request. If not, the following code snippet (which can be run outside of the apache environment) will allow you to create an account:

<?php

require_once 'weave_storage.inc';
$db = new WeaveStorage($USERNAME,1);
$db->set_path($WEAVE_DB_DIRECTORY);
$db->create_user_path();
$db->initialize();

?>