- 安裝基本套件需求
1 |
sudo apt-get install gzip git-core curl python libssl-dev pkg-config build-essential |
- 更新安裝nodejs的來源
1 |
sudo curl -sL https://deb.nodesource.com/setup | sudo bash - |
- 安裝nodejs
1 |
sudo apt-get install nodejs |
- 新增etherpad的使用者
1 2 |
sudo useradd etherpad -m -s /bin/bash -r sudo passwd etherpad |
- 將etherpad使用者加入sudoers中
1 |
sudo usermod -a -G sudo etherpad |
- 切換到etherpad使用者
1 |
su - etherpad |
- 下載etherpad檔案
1 |
wget https://github.com/ether/etherpad-lite/zipball/master |
- 安裝unzip
1 |
sudo apt-get install unzip |
- 解壓縮etherpad壓縮檔
1 |
unzip master |
- 將目錄名稱變好看一點
1 |
mv ether-etherpad-lite-3ebcaad etherpad-lite |
- 切換到etherpad-lite目錄
1 |
cd etherpad-lite |
- 複製設定檔範本
1 |
cp settings.json.template setting.json |
- 設定etherpad基本環境
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
vim setting.json # 找到以下的設定加以替換 "requireSession" : false, "sessionNoPassword" : false, "requireAuthentication": false, "requireAuthorization": true, "users": { "admin": { "password": "password", "is_admin": true }, "user": { "password": "password", "is_admin": false } }, |
- 試執行,可看 http://ip:9001 是否正常
1 |
./bin/run.sh |
- 安裝mysql、nginx
1 |
sudo apt-get install mysql-server nginx |
- 建立etherpad資料庫、設定使用者權限
1 2 3 4 |
mysql -uroot -p > create database etherpad; > grant all privileges on etherpad.* to 'etherpad'@'localhost' identified by 'password'; > exit |
- 設定etherpad資料存放使用mysql
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
vim setting.json # 註解使用dirty的部分 //"dbType" : "dirty", //"dbSettings" : { // "filename" : "var/dirty.db" // }, # 加入使用mysql的部分 "dbType" : "mysql", "dbSettings" : { "user" : "etherpad", "host" : "localhost", "password": "password", "database": "etherpad" }, |
- 試執行,並請連至 http://ip:9001 增加幾筆資料
1 |
./bin/run.sh |
- 調整資料表屬性
1 2 3 4 |
mysql -uroot -p > use etherpad; > ALTER TABLE `store` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin; > ALTER DATABASE `etherpad` CHARACTER SET utf8 COLLATE utf8_bin; |
- 設定nginx proxy
1 2 3 4 5 6 7 8 9 10 11 12 |
sudo vim /etc/nginx/sites-enabled/default # 全部內容不用留,以下面替換 server { listen 80; access_log /var/log/nginx/etherpad.log; error_log /var/log/nginx/etherpad.log; location / { proxy_pass http://localhost:9001/; proxy_set_header Host $host; proxy_buffering off; } } |
- 設定etherpad信任proxy
1 2 3 |
vim setting.json # 找到以下的設定加以替換 "trustProxy": true, |
- 創建etherpad使用之log目錄
1 |
sudo mkdir /var/log/etherpad-lite |
- 調整權限
1 |
sudo chown -R etherpad:etherpad /var/log/etherpad-lite |
- 建立etherpad系統服務設定
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
sudo vim /etc/init/etherpad.conf # 加入以下內容 description "etherpad" start on started networking stop on runlevel [!2345] env EPHOME=/home/etherpad/etherpad-lite env EPLOGS=/var/log/etherpad-lite env EPUSER=etherpad respawn pre-start script cd $EPHOME mkdir $EPLOGS ||true chown $EPUSER:admin $EPLOGS ||true chmod 0755 $EPLOGS ||true chown -R $EPUSER:admin $EPHOME/var ||true $EPHOME/bin/installDeps.sh >> $EPLOGS/error.log || { stop; exit 1; } end script script cd $EPHOME/ exec su -s /bin/sh -c 'exec "$0" "$@"' $EPUSER -- node node_modules/ep_etherpad-lite/node/server.js >> $EPLOGS/access.log 2>> $EPLOGS/error.log end script |
- 以系統服務啟動etherpad
1 |
sudo start etherpad |
- 重新讀取nginx設定
1 |
sudo service nginx reload |
- 修改npm權限,避免/admin中無法安裝plugin
1 2 3 |
cd ~/etherpad-lite sudo npm install -g express chown -R etherpad ~/.npm |
- 創建使用者管理用之資料表
1 2 3 4 5 6 7 8 |
mysql -uroot -p > use etherpad; > CREATE TABLE IF NOT EXISTS GroupPads ( GroupID int(11) NOT NULL, PadName varchar(255) COLLATE utf8_bin NOT NULL, PRIMARY KEY (GroupID, PadName) ); > CREATE TABLE IF NOT EXISTS User ( userID int(11) NOT NULL AUTO_INCREMENT, name varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', pwd varchar(255) COLLATE utf8_bin DEFAULT NULL, considered tinyint(11) DEFAULT NULL, SSO tinyint(4) DEFAULT NULL, FullName varchar(255) COLLATE utf8_bin DEFAULT NULL, considerationString varchar(50) COLLATE utf8_bin DEFAULT NULL, salt varchar(255) COLLATE utf8_bin DEFAULT NULL, active int(1) DEFAULT NULL, PRIMARY KEY (userID,name) ); > CREATE TABLE IF NOT EXISTS NotRegisteredUsersGroups ( email varchar(255) NOT NULL, groupID int(11) NOT NULL ); > CREATE TABLE IF NOT EXISTS UserGroup ( userID int(11) NOT NULL DEFAULT 0, groupID int(11) NOT NULL DEFAULT 0, Role int(11) DEFAULT NULL, PRIMARY KEY (userID,groupID) ); > CREATE TABLE IF NOT EXISTS Groups ( groupID int(11) NOT NULL AUTO_INCREMENT, name varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '', PRIMARY KEY (groupID, name ) ); > exit |
- 安裝使用者管理套件
1 2 |
cd ~/etherpad-lite npm install ep_user_pad |
- 安裝使用者管理前端介面
1 2 |
cd ~/etherpad-lite npm install ep_user_pad_frontend |
- 修正email function,這邊改用gmail為例
1 2 3 4 5 6 7 8 9 |
sudo vim node_modules/ep_user_pad/email.json # 找到以下的設定加以替換 "smtp": "true", "user": "cowman.chiang@gmail.com", "password": "password", "host": "smtp.gmail.com", "port": "465", "tls": "true", "ssl": "true", |
- 修正email function,這邊改用gmail為例
1 2 3 4 5 6 7 8 9 |
sudo vim node_modules/ep_user_pad_frontend/email.json # 找到以下的設定加以替換 "smtp": "true", "user": "cowman.chiang@gmail.com", "password": "password", "host": "smtp.gmail.com", "port": "465", "tls": "true", "ssl": "true", |
- 修正hooks.js,不然會發生錯誤
1 2 3 4 5 |
sudo vim node_modules/ep_user_pad/hooks.js # 註解下面這一行 //settings.encryptPassword = function (password, salt, cb) { # 以下面這一行取代 var encryptPassword = function (password, salt, cb) { |
-
安裝顯示作者名稱的功能
cd ~/etherpad-lite
npm install ep_authornames -
建議安裝套件
(1) adminpads : 在/admin中可以管理所有的筆記
(2) authornames: 可以在筆記內容中顯示編輯的作者名稱
(3) colors : 增加筆記的顏色功能
(4) draw : 提供畫圖的功能
(5) headings : 提供使用標題字型的功能
(6) historicalsearch : 提供在筆記編輯歷史中搜尋的功能
(7) padlist : 以/list顯示所有的筆記
(8) user_pad : 提供使用者、群組及權限的管理方式
(9) user_pad_forntend : user_pad的使用者介面 -
修正圖檔路徑問題
1 2 3 4 5 6 7 8 |
vim node_modules/ep_user_pad_frontend/templates/group.ejs vim node_modules/ep_user_pad_frontend/templates/public_pad.ejs vim node_modules/ep_user_pad_frontend/templates/public_pad_logged_in.ejs vim node_modules/ep_user_pad_frontend/templates/pad.ejs # 上述兩個檔案是修正下面這部分 img src="./static/plugins/ep_user_pad_frontend/static/images/pad-illustration-01.png" alt="Etherpad" # 修正為 img src="../static/plugins/ep_user_pad_frontend/static/images/pad-illustration-01.png" alt="Etherpad" |
pre lang=”bash”>vim node_modules/ep_user_pad_frontend/static/css/styles.less
上述這個檔案是修正下面這部分
.at2x(‘images/close-cyan-12.png’);
修正為
.at2x(‘../images/close-cyan-12.png’);
下面這句
list-style-image: url(images/users-cyan-16.png);
修正為
list-style-image: url(../images/users-cyan-16.png
- 設定 Log rotation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
sudo vim /etc/logrotate.d/etherpad-lite # 加入以下內容 /var/log/etherpad-lite/*.log { rotate 4 weekly missingok notifempty compress delaycompress sharedscripts postrotate restart etherpad-lite >/dev/null 2>&1 || true endscript } |
- 加入開機啟動
1 2 3 |
sudo vim /etc/rc.local # 加入下面 /sbin/start etherpad start |