Cách cài đặt Etherpad Collaborative Web Editor trên AlmaLinux 8

theanh

Administrator
Nhân viên
Etherpad là ứng dụng chỉnh sửa miễn phí, mã nguồn mở, dựa trên web cho phép bạn chỉnh sửa tài liệu thông qua trình duyệt web. Nó rất giống với trình chỉnh sửa nhiều người chơi giúp bạn viết bài viết, thông cáo báo chí, danh sách việc cần làm, v.v. cùng với bạn bè, bạn học hoặc đồng nghiệp, tất cả đều làm việc trên cùng một tài liệu cùng một lúc. Nó cung cấp một bộ plugin để tùy chỉnh phiên bản Etherpad cho phù hợp với nhu cầu của bạn.

Bài đăng này sẽ chỉ cho bạn cách cài đặt Etherpad với Nginx và Let's Encrypt SSL trên Alma Linux 8.

Điều kiện tiên quyết​

  • Máy chủ chạy Alma Linux 8.
  • Tên miền hợp lệ được trỏ bằng IP máy chủ của bạn.
  • Mật khẩu gốc được định cấu hình trên máy chủ của bạn.

Cài đặt và định cấu hình cơ sở dữ liệu MariaDB​

Etherpad sử dụng MariaDB làm cơ sở dữ liệu phụ trợ. Vì vậy, máy chủ cơ sở dữ liệu MariaDB phải được cài đặt trên máy chủ của bạn. Bạn có thể cài đặt máy chủ MariaDB bằng cách chạy lệnh sau:
Mã:
dnf install mariadb-server -y
Sau khi MariaDB được cài đặt, hãy khởi động và bật dịch vụ MariaDB bằng lệnh sau:
Mã:
systemctl start mariadb
systemctl enable mariadb
Tiếp theo, bảo mật cài đặt MariaDB và đặt mật khẩu gốc MariaDB bằng lệnh sau:
Mã:
mysql_secure_installation
Trả lời tất cả các câu hỏi như được hiển thị bên dưới:
Mã:
Enter current password for root (enter for none):
Switch to unix_socket authentication [Y/n] Y
Change the root password? [Y/n] Y
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y
Sau khi MariaDB được bảo mật, hãy đăng nhập vào MariaDB bằng lệnh sau:
Mã:
mysql -u root -p
Sau khi bạn đăng nhập, hãy tạo cơ sở dữ liệu và người dùng bằng lệnh sau lệnh:
Mã:
MariaDB [(none)]> CREATE DATABASE etherpad;
MariaDB [(none)]> CREATE USER 'etherpad'@'localhost' identified by 'password';
Tiếp theo, cấp tất cả các quyền cho cơ sở dữ liệu Etherpad bằng lệnh sau:
Mã:
MariaDB [(none)]> GRANT CREATE,ALTER,SELECT,INSERT,UPDATE,DELETE on etherpad.* to 'etherpad'@'localhost';
Tiếp theo, xóa các quyền và thoát khỏi shell MariaDB bằng lệnh sau lệnh:
Mã:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;
Sau khi hoàn tất, bạn có thể tiến hành bước tiếp theo.

Cài đặt Node.js​

Tiếp theo, bạn cũng sẽ cần cài đặt Node.js trên máy chủ của mình. Bạn có thể cài đặt bằng lệnh sau:
Mã:
curl -fsSL https://rpm.nodesource.com/setup_16.x | bash -
dnf install nodejs -y
Tiếp theo, xác minh cài đặt Node.js bằng lệnh sau:
Mã:
node --version
Bạn sẽ thấy thông báo sau đầu ra:
Mã:
v16.13.1

Cài đặt Etherpad trên Alma Linux 8​

Đầu tiên, tạo một người dùng chuyên dụng cho Etherpad bằng lệnh sau:
Mã:
adduser --system --home /opt/etherpad --create-home --user-group etherpad
Tiếp theo, cài đặt gói Git bằng lệnh sau lệnh:
Mã:
dnf install git -y
Tiếp theo, đăng nhập bằng người dùng Etherpad và tải xuống phiên bản Etherpad mới nhất bằng lệnh sau:
Mã:
su - etherpad
git clone --branch master git://github.com/ether/etherpad-lite.git
Tiếp theo, thay đổi thư mục thành thư mục đã tải xuống và chạy Etherpad bằng lệnh sau lệnh:
Mã:
cd etherpad-lite
./src/bin/run.sh
Nếu mọi thứ đều ổn, bạn sẽ nhận được kết quả sau:
Mã:
[2022-01-07 08:40:10.167] [INFO] APIHandler - Api key file "/opt/etherpad/etherpad-lite/APIKEY.txt" not found. Creating with random contents.
[2022-01-07 08:40:10.235] [INFO] server - Installed plugins:
[2022-01-07 08:40:10.246] [INFO] console - Report bugs at https://github.com/ether/etherpad-lite/issues
[2022-01-07 08:40:10.247] [INFO] console - Your Etherpad version is 1.8.16 (142a47c)
[2022-01-07 08:40:11.840] [INFO] http - HTTP server listening for connections
[2022-01-07 08:40:11.841] [INFO] console - You can access your Etherpad instance at http://0.0.0.0:9001/
[2022-01-07 08:40:11.841] [WARN] console - Admin username and password not set in settings.json. To access admin please uncomment and edit "users" in settings.json
[2022-01-07 08:40:11.841] [WARN] console - Etherpad is running in Development mode. This mode is slower for users and less secure than production mode. You should set the NODE_ENV environment variable to production by using: export NODE_ENV=production
[2022-01-07 08:40:11.841] [INFO] server - Etherpad is running
NhấnCTRL+C để dừng Etherpad. Chúng tôi sẽ cấu hình Etherpad để chạy như một daemon sau.

Tiếp theo, chỉnh sửa tệp settings.json và xác định cài đặt cơ sở dữ liệu và proxy của bạn:
Mã:
nano settings.json
Xóa các dòng sau:
Mã:
"dbType": "dirty", "dbSettings": { "filename": "var/dirty.db" },
Tiếp theo, thay đổi các mục sau dòng:
Mã:
"dbType" : "mysql", "dbSettings" : { "user": "etherpad", "host": "localhost", "port": 3306, "password": "password", "database": "etherpad", "charset": "utf8mb4" }, "trustProxy": true,
Lưu và đóng tệp, sau đó thoát khỏi người dùng Etherpad bằng lệnh sau:
Mã:
exit

Tạo tệp dịch vụ Systemd cho Etherpad​

Tiếp theo, bạn sẽ cần tạo tệp dịch vụ systemd để quản lý Etherpad. Bạn có thể tạo nó bằng lệnh sau:
Mã:
nano /etc/systemd/system/etherpad.service
Thêm các dòng sau:
Mã:
[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
Lưu và đóng tệp sau đó tải lại systemd để áp dụng thay đổi:
Mã:
systemctl daemon-reload
Tiếp theo, khởi động và kích hoạt dịch vụ Etherpad bằng lệnh sau:
Mã:
systemctl enable etherpad --now
Bây giờ bạn có thể kiểm tra trạng thái của Etherpad bằng lệnh sau lệnh:
Mã:
systemctl status etherpad
Bạn sẽ nhận được kết quả sau:
Mã:
? etherpad.service - Etherpad, a collaborative web editor. Loaded: loaded (/etc/systemd/system/etherpad.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2022-01-07 08:42:28 UTC; 5s ago Main PID: 10174 (node) Tasks: 13 (limit: 11411) Memory: 110.4M CGroup: /system.slice/etherpad.service ??10174 /usr/bin/node --experimental-worker /opt/etherpad/etherpad-lite/node_modules/ep_etherpad-lite/node/server.js
Jan 07 08:42:28 linux node[10174]: [2022-01-07 08:42:28.641] [INFO] settings - Random string used for versioning assets: dacd04e4
Jan 07 08:42:28 linux node[10174]: [2022-01-07 08:42:28.891] [INFO] server - Starting Etherpad...
Jan 07 08:42:28 linux node[10174]: [2022-01-07 08:42:28.967] [INFO] plugins - Running npm to get a list of installed plugins...
Jan 07 08:42:29 linux node[10174]: [2022-01-07 08:42:29.259] [INFO] plugins - npm --version: 6.14.15
Jan 07 08:42:32 linux node[10174]: [2022-01-07 08:42:32.139] [INFO] plugins - Loading plugin ep_etherpad-lite...
Jan 07 08:42:32 linux node[10174]: [2022-01-07 08:42:32.141] [INFO] plugins - Loaded 1 plugins
Jan 07 08:42:32 linux node[10174]: [2022-01-07 08:42:32.793] [INFO] APIHandler - Api key file read from: "/opt/etherpad/etherpad-lite/APIKEY.>
Jan 07 08:42:32 linux node[10174]: [2022-01-07 08:42:32.854] [INFO] server - Installed plugins:
Jan 07 08:42:32 linux node[10174]: [2022-01-07 08:42:32.887] [INFO] console - Report bugs at https://github.com/ether/etherpad-lite/issues
Jan 07 08:42:32 linux node[10174]: [2022-01-07 08:42:32.888] [INFO] console - Your Etherpad version is 1.8.16 (142a47c)
Lúc này, Etherpad đã được khởi động và lắng nghe trên cổng 9001. Bạn có thể kiểm tra bằng cách sử dụng lệnh sau lệnh:
Mã:
ss -antpl | grep 9001
Bạn sẽ nhận được kết quả đầu ra sau:
Mã:
LISTEN 0 128 0.0.0.0:9001 0.0.0.0:* users:(("node",pid=10174,fd=27))
Sau khi hoàn tất, bạn có thể tiến hành bước tiếp theo.

Cấu hình Nginx làm Proxy ngược cho Etherpad​

Tiếp theo, bạn sẽ cần cấu hình Nginx làm proxy ngược cho Etherpad. Trước tiên, cài đặt gói Nginx bằng lệnh sau:
Mã:
dnf install nginx -y
Sau khi Nginx được cài đặt, hãy khởi động và kích hoạt dịch vụ Nginx bằng lệnh sau:
Mã:
systemctl start nginx
systemctl enable nginx
Tiếp theo, tạo tệp cấu hình máy chủ ảo Nginx bằng lệnh sau lệnh:
Mã:
nano /etc/nginx/conf.d/etherpad.conf
Thêm các dòng sau:
Mã:
server { listen 80; server_name etherpad.exampledomain.com; access_log /var/log/nginx/etherpad.access.log; error_log /var/log/nginx/etherpad.error.log; 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; }
}
map $http_upgrade $connection_upgrade { default upgrade; '' close;
}
Lưu và đóng tệp sau đó xác minh Nginx cho bất kỳ cú pháp nào lỗi:
Mã:
nginx -t
Bạn sẽ nhận được kết quả sau:
Mã:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Cuối cùng, khởi động lại Nginx để áp dụng cấu hình thay đổi:
Mã:
systemctl restart nginx
Bây giờ bạn có thể xác minh trạng thái Nginx bằng lệnh sau:
Mã:
systemctl status nginx
Bạn sẽ nhận được thông báo sau đầu ra:
Mã:
? nginx.service - The nginx HTTP and reverse proxy server Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled) Drop-In: /usr/lib/systemd/system/nginx.service.d ??php-fpm.conf Active: active (running) since Fri 2022-01-07 08:58:36 UTC; 6s ago Process: 10238 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS) Process: 10236 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS) Process: 10234 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS) Main PID: 10240 (nginx) Tasks: 2 (limit: 11411) Memory: 3.7M CGroup: /system.slice/nginx.service ??10240 nginx: master process /usr/sbin/nginx ??10241 nginx: worker process
Jan 07 08:58:36 linux systemd[1]: nginx.service: Succeeded.
Jan 07 08:58:36 linux systemd[1]: Stopped The nginx HTTP and reverse proxy server.
Jan 07 08:58:36 linux systemd[1]: Starting The nginx HTTP and reverse proxy server...
Jan 07 08:58:36 linux nginx[10236]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Jan 07 08:58:36 linux nginx[10236]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Jan 07 08:58:36 linux systemd[1]: nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
Jan 07 08:58:36 linux systemd[1]: Started The nginx HTTP and reverse proxy server.

Cấu hình tường lửa cho Etherpad​

Tiếp theo, bạn sẽ cần cho phép các cổng 80 và 443 đi qua tường lửa firewalld. Bạn có thể cho phép chúng bằng lệnh sau:
Mã:
firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --zone=public --permanent --add-service=https
Tiếp theo, tải lại tường lửa để áp dụng các thay đổi:
Mã:
firewall-cmd --reload

Truy cập Giao diện Web Etherpad​

Bây giờ, hãy mở trình duyệt web của bạn và truy cập giao diện web Etherpad bằng URL http://etherpad.exampledomain.com. Bạn sẽ thấy màn hình sau:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22389%22%3E%3C/svg%3E


Cung cấp tên pad của bạn và nhấp vào nút OK. Bạn sẽ thấy trang Etherpad trên màn hình sau:


data:image/svg+xml,%3Csvg%20xmlns=%22http://www.w3.org/2000/svg%22%20width=%22750%22%20height=%22386%22%3E%3C/svg%3E

Bảo mật Etherpad với Let's Encrypt SSL​

Để bảo mật Etherpad với Let's Encrypt SSL, bạn phải cài đặt ứng dụng khách Certbot vào hệ thống của mình. Bạn có thể cài đặt bằng lệnh sau:
Mã:
dnf install epel-release -y
dnf install certbot -y
Tiếp theo, chạy lệnh sau để tải xuống và cài đặt Let's Encrypt SSL cho trang web Etherpad của bạn:
Mã:
certbot --nginx -d etherpad.exampledomain.com
Bạn sẽ được yêu cầu cung cấp email hợp lệ và chấp nhận điều khoản dịch vụ như hiển thị bên dưới:
Mã:
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): [emailprotected]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for etherpad.exampledomain.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/nginx/conf.d/etherpad.conf
Tiếp theo, chọn có chuyển hướng lưu lượng HTTP sang HTTPS hay không:
Mã:
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Nhập 2 và nhấn enter để bắt đầu quy trình. Sau khi chứng chỉ được cài đặt, bạn sẽ thấy kết quả sau:
Mã:
Redirecting all traffic on port 80 to ssl in /etc/nginx/conf.d/etherpad.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://etherpad.exampledomain.com
You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=etherpad.exampledomain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/etherpad.exampledomain.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/etherpad.exampledomain.com/privkey.pem Your cert will expire on 2022-04-10. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le - We were unable to subscribe you the EFF mailing list because your e-mail address appears to be invalid. You can try again later by visiting https://act.eff.org.

Kết luận​

Xin chúc mừng! Bạn đã cài đặt thành công Etherpad với Nginx và Let's Encrypt SSL trên Alma Linux 8. Bây giờ bạn có thể cài đặt thêm các plugin để mở rộng chức năng của Etherpad. Hãy thoải mái hỏi tôi nếu bạn có bất kỳ câu hỏi nào.
 
Back
Bên trên