Cách biên dịch ONLYOFFICE Document Server từ mã nguồn trên Ubuntu

theanh

Administrator
Nhân viên
ONLYOFFICE Document Server bao gồm các trình xem dựa trên web và trình chỉnh sửa cộng tác cho các tài liệu văn bản, bảng tính và bản trình bày, cung cấp khả năng tương thích cao với các định dạng OOXML (docx, xlsx, pptx). Bộ phần mềm này được phân phối theo GNU AGPL v3.0.

ONLYOFFICE Document Server có thể được tích hợp với nhiều nền tảng lưu trữ đám mây khác nhau như Nextcloud, ownCloud, Seafile, HumHub, Plone, v.v., cũng như có thể được tích hợp vào giải pháp mà bạn đang tự xây dựng. Document Server có thể được sử dụng như một phần của ONLYOFFICE Community Edition, một giải pháp mã nguồn mở miễn phí với trình chỉnh sửa trực tuyến và nền tảng cộng tác.



build_tools cho phép người dùng tự động cài đặt tất cả các thành phần cần thiết và biên dịch phiên bản mới nhất của trình chỉnh sửa trực tuyến từ mã nguồn.

Trong hướng dẫn này, chúng ta sẽ tìm hiểu cách biên dịch ONLYOFFICE Document Server cho bản cài đặt Ubuntu của bạn (Ubuntu 64 bit).

Yêu cầu hệ thống
  • CPU: Lõi kép 2 GHz trở lên
  • RAM: 2 GB trở lên
  • HDD: ít nhất 40 GB dung lượng trống
  • Ít nhất 4 GB bộ nhớ trao đổi

Bước 1: Cài đặt các phần phụ thuộc​

Trong trường hợp Python và Git chưa được cài đặt trên máy tính của bạn, hãy cài đặt chúng bằng lệnh sau:
Mã:
sudo apt-get install -y python git

Bước 2: Xây dựng mã nguồn Document Server​

Sao chép kho lưu trữ build_tools:
Mã:
git clone https://github.com/ONLYOFFICE/build_tools.git
Đi đến thư mục thích hợp:
Mã:
cd build_tools/tools/linux
Chạy tập lệnh:
Mã:
./automate.py server
Sau khi hoàn tất, Document Server đã xây dựng sẽ có sẵn trong ../../out/linux_64/onlyoffice/documentserver/ thư mục.

Bước 3: Cài đặt và cấu hình NGINX, PostgreSQL và RabbitMQ​

Document Server sử dụng NGINX làm máy chủ web và PostgreSQL làm cơ sở dữ liệu. RabbitMQ cũng được yêu cầu để hoạt động chính xác.

1. Cài đặt và cấu hình NGINX​

Cài đặt NGINX bằng lệnh này:
Mã:
sudo apt-get install nginx
Vô hiệu hóa trang web mặc định:
Mã:
sudo rm -f /etc/nginx/sites-enabled/default
Thiết lập trang web mới. Tạo tệp /etc/nginx/sites-available/onlyoffice-documentserver chứa dữ liệu sau:
Mã:
map $http_host $this_host {
 "" $host;
 default $http_host;
}
map $http_x_forwarded_proto $the_scheme {
 default $http_x_forwarded_proto;
 "" $scheme;
}
map $http_x_forwarded_host $the_host {
 default $http_x_forwarded_host;
 "" $this_host;
}
map $http_upgrade $proxy_connection {
 default upgrade;
 "" close;
}
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $proxy_connection;
proxy_set_header X-Forwarded-Host $the_host;
proxy_set_header X-Forwarded-Proto $the_scheme;
server {
 listen 0.0.0.0:80;
 listen [::]:80 default_server;
 server_tokens off;
 rewrite ^\/OfficeWeb(\/apps\/.*)$ /web-apps$1 redirect;
 location / {
 proxy_pass http://localhost:8000;
 proxy_http_version 1.1;
 }
 location /spellchecker/ {
 proxy_pass http://localhost:8080/;
 proxy_http_version 1.1;
 }
}
Thêm liên kết tượng trưng đến trang web mới tạo vào /etc/nginx/sites-available thư mục:
Mã:
sudo ln -s /etc/nginx/sites-available/onlyoffice-documentserver /etc/nginx/sites-enabled/onlyoffice-documentserver
Khởi động lại NGINX:
Mã:
sudo nginx -s reload

2. Cài đặt và cấu hình PostgreSQL​

Cài đặt PostgreSQL:
Mã:
sudo apt-get install postgresql
Tạo cơ sở dữ liệu và người dùng PostgreSQL (nhập ‘onlyoffice’ cho cả người dùng và mật khẩu):
Mã:
sudo -i -u postgres psql -c "CREATE DATABASE onlyoffice;"
sudo -i -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';"
sudo -i -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"
Cấu hình cơ sở dữ liệu:
Mã:
psql -hlocalhost -Uonlyoffice -d onlyoffice -f ../../out/linux_64/onlyoffice/documentserver/server/schema/postgresql/createdb.sql
Lệnh trên chỉ có một dòng! Nhập mật khẩu ‘onlyoffice’ khi bạn được yêu cầu cung cấp mật khẩu cho người dùng PostgreSQL onlyoffice.

3. Cài đặt RabbitMQ​

Cài đặt RabbitMQ bằng lệnh sau:
Mã:
sudo apt-get install rabbitmq-server

Bước 4: Tạo dữ liệu phông chữ​

Thực hiện các lệnh:
Mã:
cd out/linux_64/onlyoffice/documentserver/
mkdir fonts
LD_LIBRARY_PATH=${PWD}/server/FileConverter/bin server/tools/allfontsgen \
 --input="${PWD}/core-fonts" \
 --allfonts-web="${PWD}/sdkjs/common/AllFonts.js" \
 --allfonts="${PWD}/server/FileConverter/bin/AllFonts.js" \
 --images="${PWD}/sdkjs/common/Images" \
 --selection="${PWD}/server/FileConverter/bin/font_selection.bin" \
 --output-web='fonts' \
 --use-system="true"

Bước 5: Tạo chủ đề trình bày​

Chạy các lệnh sau:
Mã:
cd out/linux_64/onlyoffice/documentserver/
Mã:
LD_LIBRARY_PATH=${PWD}/server/FileConverter/bin server/tools/allthemesgen \
 --converter-dir="${PWD}/server/FileConverter/bin"\
 --src="${PWD}/sdkjs/slide/themes"\
 --output="${PWD}/sdkjs/common/Images"

Bước 6: Chạy Document Server​

Tất cả các thành phần của ONLYOFFICE Document Server đều chạy dưới dạng các quy trình nền trước. Bạn cần tách các bảng điều khiển thiết bị đầu cuối để chạy chúng hoặc khởi chạy các công cụ cụ thể cho phép chạy các quy trình nền trước ở chế độ nền.

Khởi động dịch vụ FileConverter:
Mã:
cd out/linux_64/onlyoffice/documentserver/server/FileConverter
LD_LIBRARY_PATH=$PWD/bin NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./converter
Khởi động dịch vụ SpellChecker:
Mã:
cd out/linux_64/onlyoffice/documentserver/server/SpellChecker
NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./spellchecker
Khởi động dịch vụ DocService:
Mã:
cd out/linux_64/onlyoffice/documentserver/server/DocService
NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./docservice
Vậy là xong! Bây giờ bạn có thể chọn một trong các tùy chọn về cách sử dụng ONLYOFFICE Document Server (trình chỉnh sửa trực tuyến) được mô tả trong phần giới thiệu: tích hợp với bất kỳ dịch vụ lưu trữ đám mây nào hoặc tích hợp vào giải pháp của riêng bạn hoặc cùng với ONLYOFFICE Community Server.
 
Back
Bên trên