Etherpadは、ブラウザでリアルタイムに共同編集を提供するオープンソースのオンラインエディタです。 Node.jsで記述されており、WordPress、Drupal、Odoo、Discourse、Joomlaなどのさまざまなプラットフォームで動作するように自己ホストすることができます。
このチュートリアルでは、MariaDBデータベースを使用してデータを保存し、EtherpadをRockyLinux8サーバーにインストールします。また、アプリケーションのリバースプロキシとしてNginxを使用し、Let's Encryptを使用してSSL証明書をインストールして、EtherpadインスタンスへのHTTPS接続を有効にします。
-
RockyLinux8を実行しているシステム。
-
sudo権限を持つroot以外のユーザー。
-
サーバーを指すドメイン名。
-
Nodejsがインストールされました。 RockyLinux8サーバーへのNodejsのインストールに関するガイドに従ってください。指定された2つの方法のいずれかを使用してください。
-
すべてが更新されていることを確認してください。
$ sudo dnf update
RockyLinuxはFirewalledFirewallを使用しています。ファイアウォールのステータスを確認してください。
$ sudo firewall-cmd --state running
これは、正常に稼働していることを示しています。
ファイアウォールはさまざまなゾーンで機能し、パブリックゾーンがデフォルトのゾーンであり、これを使用します。ファイアウォールでアクティブなすべてのサービスとポートを一覧表示します。
$ sudo firewall-cmd --permanent --list-services
次の出力が表示されます。
cockpit dhcpv6-client ssh
HTTPおよびHTTPSポートを許可します。
$ sudo firewall-cmd --permanent --add-service=http $ sudo firewall-cmd --permanent --add-service=https
9001を開きます Etherpadアプリケーションで使用されるポート。
$ sudo firewall-cmd --permanent --add-port=9001/tcp
ファイアウォールのステータスを再確認してください。
$ sudo firewall-cmd --permanent --list-services
同様の出力が表示されるはずです。
cockpit dhcpv6-client http https ssh
ファイアウォールをリロードして変更を有効にします。
$ sudo firewall-cmd --reload
Etherpadをインストールする前に、Gitをインストールする必要があります。次のコマンドを実行してGitをインストールします。
$ sudo dnf install git
インストールを確認します。
$ git --version git version 2.27.0
初期構成を追加します。
$ git config --global user.name "YourName" $ git config --global user.email "[email protected]"
設定した構成を一覧表示します。
$ git config --list user.name=YourName [email protected]
MariaDBデータベースを使用してEtherpadのデータを保存するため、最初にインストールして構成する必要があります。
RockyLinuxAppStreamリポジトリにはMariaDBが付属しています。インストールされているMariaDBの利用可能なすべてのバージョンを一覧表示するには、次のコマンドを実行します。
$ sudo dnf module list mariadb Last metadata expiration check: 1:15:26 ago on Thu 21 Oct 2021 10:20:01 AM UTC. Rocky Linux 8 - AppStream Name Stream Profiles Summary mariadb 10.3 [d] client, galera, server [d] MariaDB Module mariadb 10.5 client, galera, server [d] MariaDB Module Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled
デフォルトバージョンは10.3に設定されています。ただし、次のコマンドを使用して最新バージョンをインストールできます。
$ sudo dnf module enable mariadb:10.5
MariaDBをインストールします。
$ sudo dnf install mariadb-server
MariaDBサービスを有効にして開始します。
$ sudo systemctl enable mariadb --now
サービスのステータスを確認してください。
$ sudo systemctl status mariadb
MariaDBサーバーを保護します。
$ sudo mysql_secure_installation
さまざまなプロンプトが表示されます。次のように答えてください。
Enter current password for root (enter for none): Press Enter Switch to unix_socket authentication [Y/n] Type y Change the root password? [Y/n] Type n Remove anonymous users? [Y/n] Type y Disallow root login remotely? [Y/n] Type y Remove test database and access to it? [Y/n] Type y Reload privilege tables now? [Y/n] Type y
これで、次のコマンドを使用してMariaDBサーバーに接続できます。
$ sudo mysql
MariaDBシェルにログインします。
$ sudo mysql
Etherpad用の新しいデータベースを作成します。
$ create database `etherpad_lite_db`;
新しいデータベースユーザーを作成します。
$ CREATE USER 'etherpaduser'@'localhost' identified by 'password';
強力なパスワードを使用してください。
データベースに対する権限をユーザーに付与します。
$ grant CREATE,ALTER,SELECT,INSERT,UPDATE,DELETE on `etherpad_lite_db`.* to '<etherpaduser>'@'localhost';に付与します。
MySQLシェルを終了します。
$ exit
Etherpadをインストールするには、ソースコードをダウンロードしてビルドします。
最初のステップは、新しいetherpadを作成することです 次のコマンドを使用するユーザー。
$ sudo adduser --system --home /opt/etherpad --create-home --user-group etherpad
このコマンドは、--systemを作成します ユーザー。つまり、ログインできず、パスワードもありません。また、ホームディレクトリ/opt/etherpadも提供します。 ここからEtherpadをダウンロードします。 --create-home flagは、正しい権限でホームディレクトリを作成します。 --user-group flagは、ユーザー名と同じ名前のグループを作成します。
etherpadに切り替えます ユーザーがアプリケーションをダウンロードしてインストールします。
$ sudo -u etherpad bash
/opt/etherpadに切り替えます ディレクトリ。
[[email protected] user] cd /opt/etherpad
Etherpadリポジトリを/opt/etherpadに複製します ディレクトリ。
[[email protected] ~]$ git clone --branch master git://github.com/ether/etherpad-lite.git
新しくダウンロードしたディレクトリに切り替えます。
[[email protected] ~]$ cd etherpad-lite
Etherpadのrun.shを実行します 依存関係を設定およびインストールするためのスクリプト。
[[email protected] etherpad-lite]$ src/bin/run.sh
URL http://YOURSERVERIP:9001を起動できます ブラウザでEtherpadを起動します。次の画面が表示されます。
上記のインストールに問題があります。ノードをフォアグラウンドで実行した状態で、現在のシェルを開いたままにしておく必要があります。永続的にインストールするには、Etherpadをサービスとして実行する必要があります。ターミナルでCtrl+Cを押して、Etherpadの実行を停止します。
先に進む前に、いくつかの設定を設定し、必要に応じてインストールを構成する必要があります。 Etherpadはその設定をsettings.jsonに保存します インストールディレクトリ内のファイル。
編集のためにファイルを開きます。
[[email protected] etherpad-lite]$ nano settings.json
設定ファイルはJSONとしてフォーマットされています。最初に構成する必要があるのはデータベース設定です。
次のコードを見つけて、//を入力してコメントアウトします。 その前に。
// "dbType": "dirty",
// "dbSettings": {
// "filename": "var/dirty.db"
// },
次に、次のコードを見つけて、その値を次のように変更します。必ず/*を削除してください および*/ 最初と最後に。
"dbType" : "mysql",
"dbSettings" : {
"user": "etherpaduser",
"host": "localhost",
"port": 3306,
"password": "password",
"database": "etherpad_lite_db",
"charset": "utf8mb4"
},
最後に、少し下にスクロールして、trustProxyを見つけます。 値を設定してfalseから変更します trueに 。
"trustProxy": true,
この設定は、EtherpadをNginxと連携させるために必要です。
Ctrl + Xを押してファイルを保存します Yと入力します 終了したらプロンプトが表示されたら。
Etherpadユーザーシェルを終了します。
[[email protected] etherpad-lite]$ exit
起動時にEtherpadを起動し、systemctlを使用してプロセスを管理するには 、サービスファイルを作成する必要があります。
サービスファイルを作成して開きます。
$ sudo nano /etc/systemd/system/etherpad.service
次のコードを貼り付けます。
[Unit] Description=Etherpad, a collaborative web editor. After=syslog.target network.target [Service] Type=simple User=etherpad Group=etherpad WorkingDirectory=/opt/etherpad Environment=NODE_ENV=production ExecStart=/usr/bin/node --experimental-worker /opt/etherpad/etherpad-lite/node_modules/ep_etherpad-lite/node/server.js Restart=always [Install] WantedBy=multi-user.target
Ctrl + Xを押してファイルを保存します Yと入力します 終了したらプロンプトが表示されたら。
サービスデーモンをリロードして、新しい構成をプルします。
$ sudo systemctl daemon-reload
Etherpadサービスの開始を有効にします。
$ sudo systemctl enable etherpad --now
サービスのステータスを確認してください。
$ sudo systemctl status etherpad
? etherpad.service - Etherpad, a collaborative web editor.
Loaded: loaded (/etc/systemd/system/etherpad.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2021-10-21 15:06:53 UTC; 6s ago
Main PID: 47228 (node)
Tasks: 13 (limit: 11411)
Memory: 102.8M
CGroup: /system.slice/etherpad.service
??47228 /usr/bin/node --experimental-worker /opt/etherpad/etherpad-lite/node_modules/ep_etherpad-lite/node/server.js
.......
Let's Encryptを使用してSSL証明書をインストールするには、Certbotツールをインストールする必要があります。
まず、EPELリポジトリをダウンロードしてインストールする必要があります。
$ sudo dnf install epel-release
次のコマンドを実行して、Certbotをインストールします。
$ sudo dnf install certbot
SSL証明書を生成します。
$ sudo certbot certonly --standalone --agree-tos --preferred-challenges http -m [email protected] -d example.com
上記のコマンドは、証明書を/etc/letsencrypt/live/etherpad.example.comにダウンロードします。 サーバー上のディレクトリ。
Diffie-Hellmanグループを生成します 証明書。
$ sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
Let'sEncryptの自動更新用のチャレンジWebルートディレクトリを作成します。
$ sudo mkdir -p /var/lib/letsencrypt
Cronジョブを作成してSSLを更新します。証明書を確認し、必要に応じて更新するために毎日実行されます。そのためには、まず、ファイル/etc/cron.daily/certbot-renewを作成します。 開いて編集します。
$ sudo nano /etc/cron.daily/certbot-renew
次のコードを貼り付けます。
#!/bin/sh certbot renew --cert-name etherpad.example.com --webroot -w /var/lib/letsencrypt/ --post-hook "systemctl reload nginx"
Ctrl + Xを押してファイルを保存します Yと入力します プロンプトが表示されたら。
タスクファイルの権限を変更して実行可能にします。
$ sudo chmod +x /etc/cron.daily/certbot-renew
Rocky Linuxには、古いバージョンのNginxが付属しています。最新バージョンをインストールするには、Nginxリポジトリを追加する必要があります。
ファイル/etc/yum.repos.d/nginx.repoを作成して開きます 編集用。
$ sudo nano /etc/yum.repos.d/nginx.repo
次のコードを貼り付けます。
[nginx-stable] name=nginx stable repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=1 enabled=1 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true [nginx-mainline] name=nginx mainline repo baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/ gpgcheck=1 enabled=0 gpgkey=https://nginx.org/keys/nginx_signing.key module_hotfixes=true
Ctrl + Xを押してファイルを保存します Yと入力します 終了したらプロンプトが表示されたら。
Nginxをインストールします。
$ sudo dnf install nginx
Nginxサービスを有効にします。
$ sudo systemctl enable nginx
次に、/etc/nginx/conf.d/etherpad.confを作成して開きます 編集用。
$ sudo nano /etc/nginx/conf.d/etherpad.conf
次のコードを貼り付けます。
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name etherpad.example.com;
access_log /var/log/nginx/etherpad.access.log;
error_log /var/log/nginx/etherpad.error.log;
ssl_certificate /etc/letsencrypt/live/etherpad.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/etherpad.example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/etherpad.example.com/chain.pem;
ssl_session_timeout 5m;
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
ssl_stapling on;
ssl_stapling_verify on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
location / {
rewrite ^/$ / break;
rewrite ^/locales/(.*) /locales/$1 break;
rewrite ^/locales.json /locales.json break;
rewrite ^/admin(.*) /admin/$1 break;
rewrite ^/p/(.*) /p/$1 break;
rewrite ^/static/(.*) /static/$1 break;
rewrite ^/pluginfw/(.*) /pluginfw/$1 break;
rewrite ^/javascripts/(.*) /javascripts/$1 break;
rewrite ^/socket.io/(.*) /socket.io/$1 break;
rewrite ^/ep/(.*) /ep/$1 break;
rewrite ^/minified/(.*) /minified/$1 break;
rewrite ^/api/(.*) /api/$1 break;
rewrite ^/ro/(.*) /ro/$1 break;
rewrite ^/error/(.*) /error/$1 break;
rewrite ^/jserror(.*) /jserror$1 break;
rewrite ^/redirect(.*) /redirect$1 break;
rewrite /favicon.ico /favicon.ico break;
rewrite /robots.txt /robots.txt break;
rewrite /(.*) /p/$1;
proxy_pass http://127.0.0.1:9001;
proxy_buffering off;
proxy_set_header Host $host;
proxy_pass_header Server;
# proxy headers
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
# websocket proxying
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
# we're in the http context here
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
# enforce HTTPS
server {
listen 80;
listen [::]:80;
server_name etherpad.example.com;
return 301 https://$host$request_uri;
}
Ctrl + Xを押してファイルを保存します Yと入力します 終了したらプロンプトが表示されたら。
Nginx構成ファイルの構文を確認します。
$ sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
次のエラーが発生した場合は、ファイル/etc/nginx/nginx.confを編集する必要があります 変数server_names_hash_bucket_sizeのサイズを追加/調整します 。
nginx: [emerg] could not build the server_names_hash, you should increase server_names_hash_bucket_size
ファイル/etc/nginx/nginx.confを開きます 編集用。
$ sudo nano /etc/nginx/nginx.conf
include /etc/nginx/conf.d/*.conf;の行の前に次の行を追加します 。
server_names_hash_bucket_size 64;
Ctrl + Xを押してファイルを保存します Yと入力します プロンプトが表示されたら。 Nginxを再度検証します。
最後に、Nginxサービスを開始して、新しい構成を有効にします。
$ sudo systemctl start nginx
URL https://etherpad.example.comを起動します ブラウザでEtherpadホームが開きます。これを使用して、ドキュメントを編集したり、共同編集者を招待したりできます。
Etherpadの更新は簡単です。最初のステップは、Etherpadユーザーシェルに切り替えることです。
$ sudo -u etherpad bash
/opt/etherpad/etherpad-liteに切り替えます ディレクトリ。
[[email protected] user] cd /opt/etherpad/etherpad-lite
最新のEtherpadリポジトリを/opt/etherpad/etherpad-liteにプルします ディレクトリ。
[[email protected] ~]$ git pull origin
Etherpadのrun.shを実行します 最新バージョンのEtherpadをセットアップするためのスクリプト。
[[email protected] etherpad-lite]$ src/bin/run.sh
このチュートリアルでは、Nginxサーバーを使用してEtherpad Collaborative Editorをセットアップし、Let'sEncryptSSL証明書を使用して保護します。 Etherpadのインストールはすぐに使用でき、認証されたユーザー、プラグイン、ユーザーインターフェイスのカスタマイズなどの機能を拡張できます。
ご不明な点がございましたら、下のコメント欄に投稿してください。