下载编译工具

https://github.com/ONLYOFFICE/build_tools/tree/v7.1.1.76

重命名压缩包

build_tools-7.1.1.76.zip => build_tools.tar.gz

包括文件夹名称,上传到linux服务器并解压。

修改编译工具Dockerfile

进入文件夹build_tools,编辑Dockerfile,最后一个server为添加内容

FROM ubuntu:16.04

ENV TZ=Etc/UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get -y update && \
    apt-get -y install python \
                       python3 \
                       sudo
RUN rm /usr/bin/python && ln -s /usr/bin/python2 /usr/bin/python
ADD . /build_tools
WORKDIR /build_tools

CMD cd tools/linux && \
    python3 ./automate.py server

制作编译工具镜像

docker build --network host -t onlyoffice ./

启动编译工具容器

docker run -dit --net host --name onlyoffice onlyoffice:latest bash

注意:不要自动启动编译程序,否则一个步骤失败要全部重新来。

启动编译工具程序

docker exec -it onlyoffice bash
cd tools/linux
python3 ./automate.py server

编译过程顺利大概需要一个下午,如果出现github访问失败编译中断重新执行 python3 ./automate.py server 继续编译。

解除20个连接数限制

在容器中修改文件/server/Common/sources/constants.js,现在设置成200个连接数。

exports.LICENSE_CONNECTIONS = 200;

修改build_tools/tools/linux/automate.py 文件

build_tools_params = ["--branch", branch, 
                      "--module", modules, 
                      "--update", "0", #此处修改为0,否则会覆盖你修改的文件
                      "--qt-dir", os.getcwd() + "/qt_build/Qt-5.9.9"]

再次执行编译

python3 ./automate.py server

拷贝编译

编译结束后需要将编译出的程序拷贝出来,否则整个镜像大概有30GB。

docker exec -it onlyoffice bash
cd /build_tools
tar zcvf out.tar.gz out
exit
docker cp onlyoffice:/build_tools/out.tar.gz ./

拷贝出来的压缩包大概1.5G。

重做docker镜像

新建bin文件夹

编辑启动文件

bin/converter.sh

#!/bin/bash

cd /out/linux_64/onlyoffice/documentserver/server/FileConverter

LD_LIBRARY_PATH=$PWD/bin NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./converter

bin/docservice.sh

#!/bin/bash

cd /out/linux_64/onlyoffice/documentserver/server/DocService

NODE_ENV=development-linux NODE_CONFIG_DIR=$PWD/../Common/config ./docservice

bin/example.sh

#!/bin/bash

cd /out/linux_64/onlyoffice/documentserver-example

NODE_ENV=development-linux NODE_CONFIG_DIR=/out/linux_64/onlyoffice/documentserver-example/config ./example

bin/run-document-server.sh

#!/bin/bash

nohup sh /out/linux_64/bin/converter.sh > /var/log/onlyoffice/converter.log &
nohup sh /out/linux_64/bin/docservice.sh > /var/log/onlyoffice/docservice.log &
#如果不需要例子程序可以不启动example
nohup sh /out/linux_64/bin/example.sh > /var/log/onlyoffice/example.log &

tail -f /var/log/onlyoffice/converter.log /var/log/onlyoffice/docservice.log /var/log/onlyoffice/example.log

赋予执行权限

chmod +x bin/*

将bin目录打成压缩包

tar zcvf bin.tar.gz bin

新的Dockerfile内容如下

FROM ubuntu:16.04

ENV TZ=Etc/UTC

ADD out.tar.gz /
ADD bin.tar.gz /out/linux_64/

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
    && 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"

WORKDIR /out

EXPOSE 8000 3000

ENTRYPOINT ["/out/linux_64/bin/run-document-server.sh"]

搭建运行环境

docker-compose.yml

version: '3.1'

services:
  nginx:
    image: nginx:1.23.1-alpine
    container_name: nginx
    network_mode: "host"
    restart: always
    volumes:
      - /data/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
      - /data/nginx/logs:/etc/nginx/logs/
      - /data/nginx/cert:/etc/nginx/cert/
      - /data/nginx/html:/etc/nginx/html/
    ports:
      - '80:80'
      - '443:443'
  postgres:
    image: postgres:12.12
    container_name: postgres
    restart: always
    environment:
      POSTGRES_PASSWORD: 密码
      PGDATA: /var/lib/postgresql/data/pgdata
      TZ: Asia/Shanghai
    volumes:
      - /data/postgresql/data:/var/lib/postgresql/data
      - /data/postgresql/archivedir:/var/lib/postgresql/archivedir
    ports:
      - '5432:5432'
  rabbitmq:
    image: rabbitmq:3.10.7-management
    container_name: rabbitmq
    restart: always
    extra_hosts:
      - "主机名:IP"
    volumes:
      - /data/rabbitmq/lib:/var/lib/rabbitmq
      - /data/rabbitmq/etc:/etc/rabbitmq
      - /data/rabbitmq/log:/var/log/rabbitmq
    environment:
      RABBITMQ_DEFAULT_VHOST: 主机名
      RABBITMQ_DEFAULT_USER: admin
      RABBITMQ_DEFAULT_PASS: 密码
    ports:
      - '5672:5672'
  onlyoffice:
    image: onlyoffice:1.0.0
    container_name: onlyoffice
    restart: always
    extra_hosts:
     - "域名:IP"
    volumes:
      - /data/onlyoffice/config/default.json:/out/linux_64/onlyoffice/documentserver/server/Common/config/default.json
      - /data/onlyoffice/log:/var/log/onlyoffice
      - /data/onlyoffice/files:/out/linux_64/onlyoffice/documentserver-example/files
      - /data/onlyoffice/lib:/out/linux_64/onlyoffice/documentserver/server/App_Data
      - /data/onlyoffice/main/documenteditor-app.js:/out/linux_64/onlyoffice/documentserver/web-apps/apps/documenteditor/main/app.js
   environment:
      - NODE_TLS_REJECT_UNAUTHORIZED=0 #S3为自建证书时不验证证书
   ports:
      - '8000:8000'
      - '3001:3000'

配置中间件

nginx

创建文件夹

mkdir -p /data/nginx/conf
mkdir -p /data/nginx/logs
mkdir -p /data/nginx/html
mkdir -p /data/nginx/cert

vi /data/nginx/conf/nginx.conf

配置文件nginx.conf内容如下

    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;

    upstream example {
        server 127.0.0.1:3000;
    }

    upstream docservice {
        server 127.0.0.1:8000;#分布式部署时可填写多个
    }

    server {
        listen 80;
        server_name localhost;
        server_tokens off;
        #rewrite ^\/OfficeWeb(\/apps\/.*)$ /web-apps$1 redirect;
        location / {
            proxy_pass http://docservice/;
            proxy_http_version 1.1;
        }

        location /example/ {
            proxy_pass http://example/;

            proxy_set_header X-Forwarded-Host $the_host;
            proxy_set_header X-Forwarded-Proto $the_scheme;
            proxy_set_header X-Forwarded-Path /example;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            sub_filter_types *;
            sub_filter_once off;
            sub_filter '127.0.0.1:8000' '替换为域名或IP';
        }
    }

启动nginx

docker-compose -f docker-compose.yml up -d nginx
postgresql

创建文件夹

mkdir -p /data/postgresql/archivedir
mkdir -p /data/postgresql/data

启动数据库

docker-compose -f docker-compose.yml up -d postgres

进入数据库容器中执行SQL

su - postgres

psql -c "CREATE DATABASE onlyoffice;"
psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';"
psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"

psql -hlocalhost -Uonlyoffice -d onlyoffice -f ./createdb.sql

createdb.sql需要从编译工具容器拷贝到数据库容器,路径:/build_tools/out/linux_64/onlyoffice/documentserver/server/schema/postgresql/createdb.sql

rabbitmq

创建文件夹

mkdir -p /data/rabbitmq/etc
mkdir -p /data/rabbitmq/lib
mkdir -p /data/rabbitmq/log
chmod 0777 -R /data/rabbitmq/
vi /data/rabbitmq/etc/enabled_plugins

配置文件enabled_plugins内容如下

[rabbitmq_management,rabbitmq_prometheus].

启动MQ

docker-compose -f docker-compose.yml up -d rabbitmq
onlyoffice

创建文件夹

mkdir -p /data/onlyoffice/files
mkdir -p /data/onlyoffice/lib
mkdir -p /data/onlyoffice/log
mkdir -p /data/onlyoffice/config

chmod 0777

修改配置文件/data/onlyoffice/config/default.json

{
    "statsd": {
        "useMetrics": false,
        "host": "localhost",
        "port": "8125",
        "prefix": "ds."
    },
    "log": {
        "filePath": "",
        "options": {
            "replaceConsole": true
        }
    },
    "queue": {
        "type": "rabbitmq",
        "visibilityTimeout": 300,
        "retentionPeriod": 900
    },
    "storage": {
       "name": "storage-s3",
        "fs": {
            "folderPath": "",
            "urlExpires": 900,
            "secretString": "verysecretstring"
        },
        "region": null,
        "endpoint": "https://S3地址/",
        "bucketName": "桶名称",
        "storageFolderName": "保存路径",
        "urlExpires": 604800,
        "accessKeyId": "AK",
        "secretAccessKey": "SK",
        "useRequestToGetUrl": true,
        "useSignedUrl": true,
        "sslEnabled": false,
        "s3ForcePathStyle": true,#禁止转为桶名.S3地址
        "externalHost": ""  },
    "rabbitmq": {
        "url": "amqp://admin:密码@IP:5672/主机名",
        "socketOptions": {},
        "exchangepubsub": "ds.pubsub",
        "queueconverttask": "ds.converttask",
        "queueconvertresponse": "ds.convertresponse",
        "exchangeconvertdead": "ds.exchangeconvertdead",
        "queueconvertdead": "ds.convertdead",
        "queuedelayed": "ds.delayed"
    },
    "activemq": {
        "connectOptions": {
            "port": 5672,
            "host": "localhost",
            "name": "admin",
            "reconnect": false
        },
        "queueconverttask": "ds.converttask",
        "queueconvertresponse": "ds.convertresponse",
        "queueconvertdead": "ActiveMQ.DLQ",
        "queuedelayed": "ds.delayed",
        "topicpubsub": "ds.pubsub"
    },
    "dnscache": {
        "enable" : true,
        "ttl" : 300,
        "cachesize" : 1000
    },
    "openpgpjs": {
        "config": {
        },
        "encrypt": {
            "passwords": ["verysecretstring"]
        },
        "decrypt": {
            "passwords": ["verysecretstring"]
        }
    },
    "wopi": {
        "enable": false,
        "host" : "",
        "htmlTemplate" : "../../web-apps/apps/api/wopi",
        "wopiZone" : "external-http",
        "favIconUrlWord" : "/web-apps/apps/documenteditor/main/resources/img/favicon.ico",
        "favIconUrlCell" : "/web-apps/apps/spreadsheeteditor/main/resources/img/favicon.ico",
        "favIconUrlSlide" : "/web-apps/apps/presentationeditor/main/resources/img/favicon.ico",
        "fileInfoBlockList" : ["FileUrl"],
        "wordView": ["pdf", "djvu", "xps", "oxps", "doc", "dotx", "dotm", "dot", "fodt", "ott", "rtf", "mht", "html", "htm", "xml", "epub", "fb2"],
        "wordEdit": ["docx", "docm", "docxf", "oform", "odt", "txt"],
        "cellView": ["xls", "xlsb", "xltx", "xltm", "xlt", "fods", "ots"],
        "cellEdit": ["xlsx", "xlsm", "ods", "csv"],
        "slideView": ["ppt", "ppsx", "ppsm", "pps", "potx", "potm", "pot", "fodp", "otp"],
        "slideEdit": ["pptx", "pptm", "odp"],
        "publicKey": "BgIAAACkAABSU0ExAAgAAAEAAQD/NVqekFNi8X3p6Bvdlaxm0GGuggW5kKfVEQzPGuOkGVrz6DrOMNR+k7Pq8tONY+1NHgS6Z+v3959em78qclVDuQX77Tkml0xMHAQHN4sAHF9iQJS8gOBUKSVKaHD7Z8YXch6F212YSUSc8QphpDSHWVShU7rcUeLQsd/0pkflh5+um4YKEZhm4Mou3vstp5p12NeffyK1WFZF7q4jB7jclAslYKQsP82YY3DcRwu5Tl/+W0ifVcXze0mI7v1reJ12pKn8ifRiq+0q5oJST3TRSrvmjLg9Gt3ozhVIt2HUi3La7Qh40YOAUXm0g/hUq2BepeOp1C7WSvaOFHXe6Hqq",
        "modulus": "qnro3nUUjvZK1i7UqeOlXmCrVPiDtHlRgIPReAjt2nKL1GG3SBXO6N0aPbiM5rtK0XRPUoLmKu2rYvSJ/K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eP6UIJorZ5D+1ybaeIVHjndpwNsIEUGUxPFLrkeiU8Rm4MJ9ahxfywcP7DjQoPGY9Ge5cBhpxfzERWf732wUD6o3+L9tvOBU00CLVjULbGZKTVE2FJMyXK9jr6Zor9Mkhomp6/8Agkr9rp+TPyelFGYEz8hAoGBAOEc09CrL3eYBkhNEcaMQzxBLvOGpg8kaDX5SaArHfl9+U9yzRqss4ARECanp9HuHfjMQo7iejao0ngDjL7BNMSaH74QlSsPOY2iOm8Qvx8/zb7g4h9r1zLjFZb3mpSA4snRZvvdiZ9ugbuVPmhXnDzRRMg45MibJeeOTJNylofRAoGBAMHfF/WutqKDoX25qZo9m74W4bttOj6oIDk1N4/c6M1Z1v/aptYSE06bkWngj9P46kqjaay4hgMtzyGruc5aojPx5MHHf5bo14+Jv4NzYtR2llrUxO+UJX7aCfUYXI7RC93GUmhpeQ414j7SNAXec58d7e+ETw+6cHiAWO4uOSTPAoGATPq5qDLR4Zi4FUNdn8LZPyKfNqHF6YmupT5hIgd8kZO1jKiaYNPL8jBjkIRmjBBcaXcYD5p85nImvumf2J9jNxPpZOpwyC/Fo5xlVROp97qu1eY7DTmodntXJ6/2SXAlnZQhHmHsrPtyG752f+HtyJJbbgiem8cKWDu+DfHybfECgYBbSLo1WiBwgN4nHqZ3E48jgA6le5azLeKOTTpuKKwNFMIhEkj//t7MYn+jhLL0Mf3PSwZU50Vidc1To1IHkbFSGBGIFHFFEzl8QnXEZS4hr/y3o/teezj0c6HAn8nlDRUzRVBEDXWMdV6kCcGpCccTIrqHzpqTY0vV0UkOTQFnDQKBgAxSEhm/gtCYJIMCBe+KBJT9uECV5xDQopTTjsGOkd4306EN2dyPOIlAfwM6K/0qWisa0Ei5i8TbRRuBeTTdLEYLqXCJ7fj5tdD1begBdSVtHQ2WHqzPJSuImTkFi9NXxd1XUyZFM3y6YQvlssSuL7QSxUIEtZHnrJTt3QDd10dj",
        "refreshLockInterval": "10m"
    },
    "services": {
        "CoAuthoring": {
            "server": {
                "port": 8000,
                "workerpercpu": 1,
                "mode": "development",
                "limits_tempfile_upload": 104857600,
                "limits_image_size": 26214400,
                "limits_image_download_timeout": {
                    "connectionAndInactivity": "2m",
                    "wholeCycle": "2m"
                },
                "callbackRequestTimeout": {
                    "connectionAndInactivity": "10m",
                    "wholeCycle": "10m"
                },
                "healthcheckfilepath": "../public/healthcheck.docx",
                "savetimeoutdelay": 5000,
                "edit_singleton": false,
                "forgottenfiles": "forgotten",
                "forgottenfilesname": "output",
                "maxRequestChanges": 20000,
                "openProtectedFile": true,
                "editorDataStorage": "editorDataMemory",
                "assemblyFormatAsOrigin": true,
                "newFileTemplate" : "../../document-templates/new",
                "downloadFileAllowExt": ["pdf"],
                "tokenRequiredParams": true
            },
            "requestDefaults": {
                "headers": {
                    "User-Agent": "Node.js/6.13",
                    "Connection": "Keep-Alive"
                },
                "gzip": true,
                "rejectUnauthorized": true  #自建证书要设置为false
            },
            "autoAssembly": {
                "enable": false,
                "interval": "5m",
                "step": "1m"
            },
            "utils": {
                "utils_common_fontdir": "null",
                "utils_fonts_search_patterns": "*.ttf;*.ttc;*.otf",
                "limits_image_types_upload": "jpg;jpeg;jpe;png;gif;bmp"
            },
            "sql": {
                "type": "postgres",
                "tableChanges": "doc_changes",
                "tableResult": "task_result",
                "dbHost": "IP",
                "dbPort": 5432,
                "dbName": "onlyoffice",
                "dbUser": "onlyoffice",
                "dbPass": "onlyoffice",
                "charset": "utf8",
                "connectionlimit": 10,
                "max_allowed_packet": 1048575,
                "pgPoolExtraOptions": {}
            },
            "redis": {
                "name": "redis",
                "prefix": "ds:",
                "host": "localhost",
                "port": 6379,
                "options": {}
            },
            "pubsub": {
                "maxChanges": 1000
            },
            "expire": {
                "saveLock": 60,
                "presence": 300,
                "locks": 604800,
                "changeindex": 86400,
                "lockDoc": 30,
                "message": 86400,
                "lastsave": 604800,
                "forcesave": 604800,
                "saved": 3600,
                "documentsCron": "0 */2 * * * *",
                "files": 86400,
                "filesCron": "00 00 */1 * * *",
                "filesremovedatonce": 100,
                "sessionidle": "0",
                "sessionabsolute": "30d",
                "sessionclosecommand": "2m",
                "pemStdTTL": "1h",
                "pemCheckPeriod": "10m",
                "updateVersionStatus": "5m",
                "monthUniqueUsers": "1y"
            },
            "ipfilter": {
                "rules": [{"address": "*", "allowed": true}],
                "useforrequest": false,
                "errorcode": 403
            },
            "request-filtering-agent" : {
                "allowPrivateIPAddress": true,
                "allowMetaIPAddress": true
            },
            "secret": {
                "browser": {"string": "secret", "file": "", "tenants": {}},
                "inbox": {"string": "secret", "file": "", "tenants": {}},
                "outbox": {"string": "secret", "file": ""},
                "session": {"string": "secret", "file": ""}
            },
            "token": {
                "enable": {
                    "browser": false,
                    "request": {
                        "inbox": false,
                        "outbox": false
                    }
                },
                "browser": {
                    "secretFromInbox": true
                },
                "inbox": {
                    "header": "Authorization",
                    "prefix": "Bearer ",
                    "inBody": false
                },
                "outbox": {
                    "header": "Authorization",
                    "prefix": "Bearer ",
                    "algorithm": "HS256",
                    "expires": "5m",
                    "inBody": false,
                    "urlExclusionRegex": ""
                },
                "session": {
                    "algorithm": "HS256",
                    "expires": "30d"
                },
                "verifyOptions": {
                    "clockTolerance": 60
                }
            },
            "plugins": {
                "uri": "/sdkjs-plugins",
                "autostart": []
            },
            "themes": {
                "uri": "/web-apps/apps/common/main/resources/themes"
            },
            "editor":{
                "spellcheckerUrl": "",
                "reconnection":{
                    "attempts": 50,
                    "delay": "2s"
                },
                "websocketMaxPayloadSize": "1.5MB"
            },
            "sockjs": {
                "sockjs_url": "",
                "websocket": true
            },
            "callbackBackoffOptions": {
                "retries": 0,
                "timeout":{
                    "factor": 2,
                    "minTimeout": 1000,
                    "maxTimeout": 2147483647,
                    "randomize": false
                },
                "httpStatus": "429,500-599"
            }
        }
    },
    "license" : {
        "license_file": "",
        "warning_limit_percents": 70,
        "packageType": 0
    },
    "FileConverter": {
        "converter": {
            "maxDownloadBytes": 104857600,
            "downloadTimeout": {
                "connectionAndInactivity": "2m",
                "wholeCycle": "2m"
            },
            "downloadAttemptMaxCount": 3,
            "downloadAttemptDelay": 1000,
            "maxprocesscount": 1,
            "fontDir": "null",
            "presentationThemesDir": "null",
            "x2tPath": "null",
            "docbuilderPath": "null",
            "docbuilderAllFontsPath": "null",
            "docbuilderCoreFontsPath": "",
            "args": "",
            "spawnOptions": {},
            "errorfiles": "",
            "streamWriterBufferSize": 8388608,
            "maxRedeliveredCount": 2,
            "inputLimits": [
                {
                "type": "docx;dotx;docm;dotm",
                "zip": {
                    "uncompressed": "50MB",
                    "template": "*.xml"
                }
                },
                {
                "type": "xlsx;xltx;xlsm;xltm",
                "zip": {
                    "uncompressed": "300MB",
                    "template": "*.xml"
                }
                },
                {
                "type": "pptx;ppsx;potx;pptm;ppsm;potm",
                "zip": {
                    "uncompressed": "50MB",
                    "template": "*.xml"
                }
                }
            ]
        }
    }
}

启动onlyoffice

docker-compose -f docker-compose.yml up -d onlyoffice

移动端限制解除

修改NGINX配置文件,在server中新增以下内容:

location /web-apps/apps/documenteditor/mobile/dist/js/app.js {
    sub_filter_types *;
    sub_filter_once off;
    sub_filter 'isSupportEditFeature=function(){return!1}' 'isSupportEditFeature=function(){return 1}';
    proxy_pass http://docservice/web-apps/apps/documenteditor/mobile/dist/js/app.js;
}

location /web-apps/apps/presentationeditor/mobile/dist/js/app.js {
    sub_filter_types *;
    sub_filter_once off;
    sub_filter 'isSupportEditFeature=function(){return!1}' 'isSupportEditFeature=function(){return 1}';
    proxy_pass http://docservice/web-apps/apps/documenteditor/mobile/dist/js/app.js;
}

location /web-apps/apps/spreadsheeteditor/mobile/dist/js/app.js {
    sub_filter_types *;
    sub_filter_once off;
    sub_filter 'isSupportEditFeature=function(){return!1}' 'isSupportEditFeature=function(){return 1}';
    proxy_pass http://docservice/web-apps/apps/documenteditor/mobile/dist/js/app.js;
}

恭喜安装成功

等待片刻后访问http://IP/example/

看到以下界面说明成功

2024-01-18T22:11:35.260355392-eqvd.png并且文件是可编辑的。

2024-01-18T22:13:19.738754599-piqd.png

待处理问题

redis在onlyoffice里似乎无用。

rabbitmq分布式部署。

参考文献

https://helpcenter.onlyoffice.com/installation/docs-community-compile.aspx

https://helpcenter.onlyoffice.com/installation/docs-connect-amazon.aspx