Etherpad-LiteをUbuntu 16.04 Linuxにインストールする方法

(1) etherpad-lite の実行ユーザ etherpad を追加する。

$ sudo adduser --system --home=/opt/etherpad --group etherpad

(2) 関連パッケージをインストールする。

$ sudo apt install git curl python libssl-dev pkg-config build-essential git-core gzip abiword python-software-properties

(3) node.js のインストール

$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -$ sudo apt-get install -y nodejs

(4) Etherpad-Lite のインストール

$ sudo su - etherpad -s /bin/bash$ cd /opt/etherpad$ git clone git://github.com/ether/etherpad-lite.git
cd etherpad-lite$ bin/run.sh

ブラウザで https://localhost:9001/ にアクセスし、ログイン画面が表示されたら OK。
起動時に「Error raised: listen EADDRINUSE」というエラーが出た場合は、etherpad-lite がデフォルトで使おうとする 9001 番ポートが既に他のプロセスで使用されていることが原因。設定ファイル /opt/etherpad/local/etherpad/etherpad-lite/settings.json を編集し、16行目付近の port を 未使用なポート番号に変更した上で、再度 run.sh を実行する。

前述の run.sh で etherpad-lite を起動すると CLI セッションを閉じた際に etherpad-lite も停止してしまう。サーバ起動時にサービスとして自動起動するように設定を行う。前述の run.sh を起動している場合は Ctrl + c で停止し、etherpad ユーザから exit しておく。

(5) etherpad-lite の自動起動設定 (サービス化)

$ sudo mkdir /var/log/etherpad-lite$ sudo touch /var/log/etherpad-lite/etherpad-lite.log$ sudo chown etherpad.etherpad /var/log/etherpad-lite$ sudo chmod -R 777 /var/log/etherpad-lite
vi /etc/init.d/etherpad-lite
#!/bin/sh
### BEGIN INIT INFO
# Provides:          etherpad-lite
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts etherpad lite
# Description:       starts etherpad lite using start-stop-daemon
### END INIT INFO
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin"
LOGFILE="/var/log/etherpad-lite/etherpad-lite.log"
EPLITE_DIR="/opt/etherpad/etherpad-lite/"
EPLITE_BIN="bin/run.sh"
USER="etherpad"
GROUP="etherpad"
DESC="Etherpad Lite"
NAME="etherpad-lite"
set -e
. /lib/lsb/init-functions
start() {
  echo "Starting $DESC... "
    start-stop-daemon --start --chuid "$USER:$GROUP" --background --make-pidfile --pidfile /var/run/$NAME.pid --exec $EPLITE_DIR/$EPLITE_BIN -- $LOGFILE || true
  echo "done"
}
#We need this function to ensure the whole process tree will be killed
killtree() {
    local _pid=$1
    local _sig=${2-TERM}
    for _child in $(ps -o pid --no-headers --ppid ${_pid}); do
        killtree ${_child} ${_sig}
    done
    kill -${_sig} ${_pid}
}
stop() {
  echo "Stopping $DESC... "
  if test -f /var/run/$NAME.pid; then
    while test -d /proc/$(cat /var/run/$NAME.pid); do
      killtree $(cat /var/run/$NAME.pid) 15
      sleep 0.5
    done
    rm /var/run/$NAME.pid
  fi
  echo "done"
}
status() {
  status_of_proc -p /var/run/$NAME.pid "" "etherpad-lite" && exit 0 || exit $?
}
case "$1" in
  start)
      start
      ;;
  stop)
    stop
      ;;
  restart)
      stop
      start
      ;;
  status)
      status
      ;;
  *)
      echo "Usage: $NAME {start|stop|restart|status}" >&2
      exit 1
      ;;
esac
exit 0
$ sudo chmod -R 777 /etc/init.d/etherpad-lite$ sudo chown -R etherpad.etherpad /etc/init.d/etherpad-lite
$ service etherpad-lite start
sudo update-rc.d etherpad-lite defaults