Sunday, March 27, 2011

Package the Weave Server - 0.1 (Manual Install)

Hello everyone, it's been a while since my last blog post. Unfortunately I had some health issues to deal with, but things have improved and I will be posting details on my packaging project followed by the labs I've completed.

Milestone 0.2 will deal with the actual packaging of Weave and the bugzilla process, for this post (0.1) I will give you some brief information on what Weave is and how to successfully install and configure it manually.

Package the Weave Server Wiki (For more details)

What is Weave?

Weave is the server component for a product you be aware of called Firefox Sync (now standard with Firefox 4.0). It allows you to backup and sychronize data from your browser or mobile client to Mozilla servers or custom ones. My project is to package Weave for inclusion on the official Fedora repos to assist in the automation and management of custom Weave servers.

Weave consists of two main components: reg-server and sync-server. The first (reg-server) handles account registration and modifications while sync-server handles data collection and management.

Installation:

Before we begin the install a number of packages will be required. Weave requires MySQL and Apache running, PHP including mbstring and mysql driver. We will also be using mercurial to clone the necessary files from Mozilla.
yum install php php-mbstring php-mysql mysql mysql-server mercurial httpd
Next we will clone the reg/sync files from Mozilla.
hg clone http://hg.mozilla.org/services/sync-server
hg clone http://hg.mozilla.org/services/reg-server
This will create directories for both Weave components. Move these to your preferred install directory as your the apache weave conf file will point to it later.

MySQL Setup

Next we will setup the weave database and management user account. I have an SQL script (modified from Anna Sobiepanek's original) which you can use to automate the process. Please download the script from my matrix account.

Note: This script will create the management account: 'weave' with a default password of 'weave', if you wish change the following line in the script with the password of your choice, otherwise leave it default:
CREATE USER 'weave'@'localhost' IDENTIFIED BY 'weave';
Make sure you've setup your root MySQL (or account with permission to create users and database) account and apply the script with the following command:
mysql -u'dbuser' -p'dbpass' < '/script/path/weave.sql'
Configuring Constants

Next we need to configure the PHP constant files for both the sync and reg components. Begin by copying the template .dist files to the same folder without the extension:
cp 'install/path/sync-server/1.1/default_constants.php.dist' '/install/path/sync-server/1.1/default_constants.php'

cp '/install/path/reg-server/1.0/weave_user_constants.php.dist' '/install/path/reg-server/1.0/weave_user_constants.php'
For the purposes of this install we will leave the constants at their default values unless you setup a custom password for the weave MySQL account. Please change the following define statements if you've done so

sync-server/1.1/default_constants.php
if (!defined('WEAVE_MYSQL_STORE_READ_PASS')) { define('WEAVE_MYSQL_STORE_READ_PASS', 'weave'); }
if (!defined('WEAVE_MYSQL_AUTH_PASS')) { define('WEAVE_MYSQL_AUTH_PASS', 'weave'); }
reg-server/1.0/weave_user_constants.php
if (!defined('WEAVE_MYSQL_AUTH_PASS')) { define('WEAVE_MYSQL_AUTH_PASS', 'weave'); }
Apache Config

Create a config file in /etc/httpd/conf.d/ called 'weave.conf' and enter the following aliases pointing to your install directories. The multiple aliases are required for backwards compatibility with older weave clients.
Alias /1.0 <path to install directory>/sync-server/1.1/index.php
Alias /1.1 <path to install directory>/sync-server/1.1/index.php
Alias /user/1.0 <path to install directory>/reg-server/1.0/index.php
Alias /user/1 <path to install directory>/reg-server/1.0/index.php
Make sure to restart the apache service after saving the config file:
service httpd restart
Client Setup (Firefox 4.0 Sync)

Mozilla has a handy Firefox Sync setup video on their website. Point the client to your custom server (http://localhost/) and test your custom weave server by creating an account and syncing.

*Note: Due to a bug with Firefox Sync Client, make sure to include the forward slash / at the end of your server address. Otherwise sync will not work.