EtherPadをUbuntu 10.04にインストールしてみた

EtherPadは、リアルタイムドキュメント編集の走りであったサービスで、メンバーがGoogle Waveの開発チームに吸収された時点でオープンソース化されて公開されています。
Ubuntu 10.04にインストールしてみたので手順をメモしておきます。

プロジェクトについて

プロジェクトはGoogle CodeとGithubにあります。

http://code.google.com/p/etherpad/

https://github.com/ether/pad
Google code版とgit版ではインストール方法が異なります。
アクティブなのはgithubの方なのでgit版で試してみました。

動かし方

プロジェクトのクローンします。

git clone https://github.com/ether/pad.git

ビルドと起動方法についてはGoogle codeのwikiInstructionsまたは、プロジェクトのルートディレクトリにあるINSTALLを参照ください。

依存するソフトウェアのインストール

INSTALLファイルには以下の様に書いてあります。

* Install the dependencies: Scala 2.7, Sun Java JDK 6, libmysql-java

自分はUbuntu 10.04で試したので以下の様にapt-getしました。

$sudo apt-get install sun-java6-jdk scala mysql-server libmysql-java

ちなみに、Scalaは2.7.7が入りました。

* Uninstall gcj if it's installed as it seems to interfere with the
  Scala compiler.  You can safely reinstall it after compiling Etherpad
  if you want to.

gcjが入っていなかったので、ここは省略。

環境変数の追加

INSTALLファイルには以下の様に書いてあります。

* Edit the file bin/exports.sh (and optionally
  etherpad/bin/etherpad.default) and change the paths to
  match your system.

Ubuntuの場合は、変更するパスはありませんのでこのステップも省略。

ビルドの実行
* Run bin/build.sh

bin/build.shを実行

$ bin/build.sh
unzipping JARs...
making cached JAR....
compiling...
compiling with 'fsc'...
compiling common...
注:net.appjet.common/util/HttpServletRequestFactory.java は推奨されない API を使用またはオーバーライドしています。
注:詳細については、-Xlint:deprecation オプションを指定して再コンパイルしてください。
注:net.appjet.common/util/HttpServletRequestFactory.java の操作は、未チェックまたは安全ではありません。
注:詳細については、-Xlint:unchecked オプションを指定して再コンパイルしてください。
compiling sars...
compiling cli...
done with cli
compiling rhino abstraction...
warning: there were deprecation warnings; re-run with -deprecation for details
one warning found
compiling appserver source...
warning: there were deprecation warnings; re-run with -deprecation for details
warning: there were unchecked warnings; re-run with -unchecked for details
two warnings found
compiling ajstdlib...
warning: there were deprecation warnings; re-run with -deprecation for details
one warning found
compilng etherpad...
compiling ooservice...
copying files...
obfuscating...
building javascript classfiles...
done.
copying cached JAR...
making JAR...
cleaning up...
done.
EtherPad用ユーザをシステムに追加
* Create a new user on your system called "etherpad"

自動起動を設定しないで試すだけなら、ユーザの追加も省略してください。

$ sudo useradd -d /home/etherpad -s /usr/sbin/nologin etherpad
MySQLにEtherPad用データベースを作成
* Create a MySQL database "etherpad" and a database user "etherpad"
$ mysql -uroot
mysql> create database etherpad character set utf8;
mysql> exit;
実行プロパティファイルを作成
* Copy etherpad/etc/etherpad.localdev-default.properties to etherpad/etc/etherpad.local.properties
$ cp etherpad/etc/etherpad.localdev-default.properties etherpad/etc/etherpad.local.properties
* Edit etherpad/etc/etherpad.local.properties and set
   etherpad.SQL_JDBC_URL
       Example etherpad.SQL_JDBC_URL = jdbc:mysql://localhost:3306/etherpad
   etherpad.SQL_PASSWORD
   etherpad.SQL_USERNAME = etherpad
   etherpad.adminPass
   topdomains
       Example: topdomains = yourhostname.com,localhost
$ vi etherpad/etc/etherpad.local.properties

とりあえず、MySQLのデータベースに接続するユーザ名/パスワードのみ設定。

etherpad.SQL_PASSWORD = 
etherpad.SQL_USERNAME = root
EtherPadの実行
* You can now run etherpad via bin/run.sh

いよいよ起動。

$ bin/run.sh

ブラウザを開いてhttp://localhost:9000にアクセスします。

[Create team site]とかできるんだ便利そう、とりあえず[Create new pad]します。

見たことのある画面が無事表示されました。

MySQLのetherpadデータベースを覗いてみると、テーブルができています。初期実行時にテーブルを定義してくれるようです。

mysql> use etherpad;
mysql> show tables;
                                                      • +
Tables_in_etherpad
                                                      • +
PAD_APOOL
PAD_AUTHORS_META
PAD_AUTHORS_TEXT
PAD_CHAT_META
PAD_CHAT_TEXT
PAD_DIAGNOSTIC
PAD_META
PAD_REVMETA_META
PAD_REVMETA_TEXT
PAD_REVS1000_META
PAD_REVS1000_TEXT
PAD_REVS100_META
PAD_REVS100_TEXT
PAD_REVS10_META
PAD_REVS10_TEXT
PAD_REVS_META
PAD_REVS_TEXT
PAD_SQLMETA
billing_adjustment
billing_invoice
billing_payment_info
billing_purchase
billing_transaction
checkout_pro_referral
checkout_purchase
checkout_referral
cpds_testtable
db_migrations
eepnet_signups
hook
hook_type
just_a_test
pad_cookie_userids
pad_guests
persistent_vars
plugin
plugin_hook
pne_tracking_data
pro_account_usage
pro_accounts
pro_accounts_auto_signin
pro_beta_signups
pro_config
pro_domains
pro_padmeta
statistics
usage_stats
                                                      • +
47 rows in set (0.03 sec)

自動起動の設定

最後にデーモンとして登録してみます。

* If you want to have Etherpad run via init, create a link
  to debian/etherpad.init from /etc/init.d/etherpad and
  enable via update-rc.d etherpad defaults ; you'll also
  need to create an etherpad user and group via
  groupadd etherpad && useradd -G etherpad etherpad 

etherpad.initには、プロジェクトのルートディレクトリが/usr/local/etherpadにあるように指定されています。

DAEMON_BASE="/usr/local/etherpad"
...
OOFFICE_LOG="/var/log/etherpad/ooffice.log"

上記のDAEMON_BASEを変更するか、プロジェクトのファイルを/usr/local/etherpadに移動する必要があります。
/usr/localに移動してみました。

$ sudo mv <プロジェクトのパス> /usr/local/etherpad
$ sudo -Rf etherpad /usr/local/etherpad/

また、/var/log/etherpadディレクトリを作成しておきます。

$ sudo mkdir /var/log/etherpad
$ sudo chown etherpad /var/log/etherpad

次に、debian/etherpad.initを/etc/init.d/etherpadとしてリンクを作って、自動起動を設定するだけです。

$ sudo ln -s /usr/local/etherpad/debian/etherpad.init /etc/init.d/etherpad
$ sudo update-rc.d etherpad defaults