Services/Sync/Server/Archived/0.3/Setup: Difference between revisions

From MozillaWiki
< Services‎ | Sync‎ | Server‎ | Archived
Jump to navigation Jump to search
No edit summary
Line 5: Line 5:
The Weave Server requires PHP with PDO and JSON support installed. This should be the case if you are running PHP 5.1+. PDO will need drivers for whatever storage and authentications engines are used.
The Weave Server requires PHP with PDO and JSON support installed. This should be the case if you are running PHP 5.1+. PDO will need drivers for whatever storage and authentications engines are used.


== Setting up the Weave Server (Sqlite backend) ==
== Setting up the Server ==


1) Unzip the weave_server.zip directory into the location you plan to serve the files from.
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:
3) Edit your apache conf files to add the following:
Line 15: Line 13:
<pre>
<pre>
Alias /weave/0.3 <full path to weave directory>/index.php
Alias /weave/0.3 <full path to weave directory>/index.php
SetEnv WEAVE_STORAGE_TYPE sqlite
SetEnv WEAVE_SQLITE_DIRECTORY <path to stores directory>
</pre>
</pre>


== Setting up the Weave Server (Mysql backend) ==


1) Unzip the weave_server.zip directory into the location you plan to serve the files from.
== Setting up Weave Authentication ==
 
Add the following to your apache conf:
 
<pre>
SetEnv WEAVE_AUTH_ENGINE [sqlite|mysql|none]
</pre>
 
=== Sqlite ===
 
Add the following parameter to your apache conf:
 
<pre>
SetEnv WEAVE_SQLITE_AUTH_DIRECTORY <path to stores directory>
</pre>
 
additionally, under the same user as your apache, create the users table
 
<pre>
$ sqlite3 <path to stores directory>/_users
SQLite version 3.4.0
sqlite> create table users (username text primary key, md5 text);
sqlite> .quit
</pre>
 
=== Mysql ===
 
Create the mysql database. Add the following tables:
 
<pre>
create table users
(
username varchar(32) primary key,
md5 varchar(32)) engine=InnoDB;
</pre>
 
Edit your apache conf files to add the following:
 
<pre>
SetEnv WEAVE_MYSQL_AUTH_HOST <db host>
SetEnv WEAVE_MYSQL_AUTH_DB <db name>
SetEnv WEAVE_MYSQL_AUTH_USER <db username>
SetEnv WEAVE_MYSQL_AUTH_PASS <db password>
</pre>
 
== Setting up Weave Storage ==
 
Add the following to your apache conf:
 
<pre>
SetEnv WEAVE_STORAGE_ENGINE [sqlite|mysql]
</pre>
 
=== Sqlite ===
 
Add the following parameter to your apache conf:
 
<pre>
SetEnv WEAVE_SQLITE_STORE_DIRECTORY <path to stores directory>
</pre>
 
To create a user db, run the following php code:
 
<pre>
<?php
  setenv(WEAVE_SQLITE_STORE_DIRECTORY, $your_path);
  $db = new WeaveStorageMysql($username, $auth_obj->get_connection());
  $db->create_user($username);
?>
</pre>
 
=== Mysql ===


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


<pre>
<pre>
Line 41: Line 107:
</pre>
</pre>


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


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


== Optional Apache Parameters ==
== Optional Apache Parameters ==

Revision as of 23:50, 20 October 2008

Pre-Setup Considerations

It is strongly recommended that the Weave Server be set up under https, or behind a firewall with an https proxy in front of it, especially if you are planning to use Apache basic authorization for access control.

The Weave Server requires PHP with PDO and JSON support installed. This should be the case if you are running PHP 5.1+. PDO will need drivers for whatever storage and authentications engines are used.

Setting up the Server

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

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

Alias /weave/0.3 <full path to weave directory>/index.php


Setting up Weave Authentication

Add the following to your apache conf:

SetEnv WEAVE_AUTH_ENGINE [sqlite|mysql|none]

Sqlite

Add the following parameter to your apache conf:

SetEnv WEAVE_SQLITE_AUTH_DIRECTORY <path to stores directory>

additionally, under the same user as your apache, create the users table

$ sqlite3 <path to stores directory>/_users
SQLite version 3.4.0
sqlite> create table users (username text primary key, md5 text);
sqlite> .quit

Mysql

Create the mysql database. Add the following tables:

create table users 
(
 username varchar(32) primary key, 
 md5 varchar(32)) engine=InnoDB;

Edit your apache conf files to add the following:

SetEnv WEAVE_MYSQL_AUTH_HOST <db host>
SetEnv WEAVE_MYSQL_AUTH_DB <db name>
SetEnv WEAVE_MYSQL_AUTH_USER <db username>
SetEnv WEAVE_MYSQL_AUTH_PASS <db password>

Setting up Weave Storage

Add the following to your apache conf:

SetEnv WEAVE_STORAGE_ENGINE [sqlite|mysql]

Sqlite

Add the following parameter to your apache conf:

SetEnv WEAVE_SQLITE_STORE_DIRECTORY <path to stores directory>

To create a user db, run the following php code:

<?php
  setenv(WEAVE_SQLITE_STORE_DIRECTORY, $your_path);
  $db = new WeaveStorageMysql($username, $auth_obj->get_connection());
  $db->create_user($username);
?>

Mysql

Create the mysql database. Add the following tables:

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;


Edit your apache conf files to add the following:

SetEnv WEAVE_MYSQL_STORE_HOST <db host>
SetEnv WEAVE_MYSQL_STORE_DB <db name>
SetEnv WEAVE_MYSQL_STORE_USER <db username>
SetEnv WEAVE_MYSQL_STORE_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)

SetEnv WEAVE_SHARE_DBH 1

If both the storage engine and authentication engine are using the same database, setting this makes both engines use the same database handler rather than opening different ones. Note that SQLite cannot use the same db for authentication and storage.

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.