本文由AI翻译

在本地服务器上编译 ONLYOFFICE 文档

简介

ONLYOFFICE 文档 是一个在线办公套件,包含文本、电子表格和演示文稿的查看器和编辑器,完全兼容 Office Open XML 格式:.docx、.xlsx、.pptx,并支持实时协作编辑。

您可以轻松地从源代码编译 ONLYOFFICE 文档,并使用专门设计的 build_tools 工具将解决方案部署在本地服务器上。build_tools 工具允许自动获取和安装编译过程所需的所有组件,以及 ONLYOFFICE 文档 正常工作所需的所有依赖项,还可以获取 ONLYOFFICE 文档 的最新版本源代码并构建其所有组件。

重要! 我们只能保证从 master 分支构建的产品正常工作。
系统要求

硬件

  • CPU:双核 2 GHz 或更高
  • 内存:至少 2 GB,但取决于主机操作系统。更多更好
  • 硬盘:至少 40 GB 的可用空间
  • 交换空间:至少 4 GB,但取决于主机操作系统。更多更好

软件

  • 操作系统:64 位 Ubuntu 16.04
该解决方案已在 Ubuntu 16.04 上测试。其他发行版可能需要一些特定操作,这里未描述。

安装依赖项

如果您的计算机上尚未安装 PythonGit,您可能需要安装它们。这可以通过以下命令完成:

sudo apt-get install -y python git

构建 ONLYOFFICE 文档源代码

  1. 克隆 build_tools 仓库:
    git clone https://github.com/ONLYOFFICE/build_tools.git
  2. 进入 build_tools/tools/linux 目录:
    cd build_tools/tools/linux
  3. 运行 automate.py 脚本,指定 server 参数以编译 ONLYOFFICE 文档
    ./automate.py server
    如果您在没有任何参数的情况下运行脚本,这将同时构建 ONLYOFFICE 文档文档生成器桌面编辑器
    ./automate.py
    如果需要,您可以通过运行带有相应参数的脚本来同时构建多个产品。要了解有关编译 文档生成器 的更多信息,您可以阅读本文。要了解有关编译 桌面编辑器 的更多信息,请参阅本文

等待脚本执行。根据您的计算机性能,这个过程可能需要相当长的时间。例如,在 Intel Core i7-7700 上至少需要 3 小时。

该脚本将编译 ONLYOFFICE 文档 的所有依赖项和组件。

构建的 ONLYOFFICE 文档 将位于 ../../out/linux_64/onlyoffice/documentserver/ 目录中。

安装和配置 NGINX、PostgreSQL 和 RabbitMQ

ONLYOFFICE 文档 使用 NGINX 作为 Web 服务器,使用 PostgreSQL 作为数据库。RabbitMQ 也是 ONLYOFFICE 文档 正常工作所需的。

安装和配置 NGINX
  1. 安装 NGINX:
    sudo apt-get install nginx
  2. 禁用默认网站:
    sudo rm -f /etc/nginx/sites-enabled/default
  3. 现在您需要设置新网站。为此,创建 /etc/nginx/sites-available/onlyoffice-documentserver 文件,内容如下:
    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;
      }  
    }
  4. 将新创建的网站的符号链接添加到 /etc/nginx/sites-available 目录:
    sudo ln -s /etc/nginx/sites-available/onlyoffice-documentserver /etc/nginx/sites-enabled/onlyoffice-documentserver
  5. 重启 NGINX 以应用更改:
    sudo nginx -s reload
安装和配置 PostgreSQL

使用以下命令安装 PostgreSQL:

sudo apt-get install postgresql

安装 PostgreSQL 后,运行以下命令创建 PostgreSQL 数据库和用户:

创建的数据库必须同时为用户和密码设置 onlyoffice
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;"

运行以下命令配置数据库:

psql -hlocalhost -Uonlyoffice -d onlyoffice -f ../../out/linux_64/onlyoffice/documentserver/server/schema/postgresql/createdb.sql
此时,系统会要求您为 onlyoffice PostgreSQL 用户提供密码。请输入 onlyoffice 密码。
安装 RabbitMQ

使用以下命令安装 RabbitMQ:

sudo apt-get install rabbitmq-server
生成字体数据
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"
生成演示主题
cd out/linux_64/onlyoffice/documentserver/
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"

运行 ONLYOFFICE 文档

所有 ONLYOFFICE 文档 组件作为前台进程运行。因此,您需要单独的终端控制台来运行它们,或者使用特定工具将前台进程在后台模式下运行。
  1. 启动 FileConverter 服务:
    cd out/linux_64/onlyoffice/documentserver/server/FileConverter
    LD_LIBRARY_PATH=$PWD/bin NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./converter
  2. 启动 DocService 服务:
    cd out/linux_64/onlyoffice/documentserver/server/DocService
    NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./docservice

在您自己的服务器上托管 ONLYOFFICE 文档,或在云端使用

文章: 标签:
浏览所有标签