ONLYOFFICE DocumnetServer installation pit record

ONLYOFFICE DocumnetServer installation pit record

1. Installation preparation:

Operating system: window server 2012 R2 and above

environment:

Installation package:

Note: Try to install the given version of the above software, otherwise many strange errors will be reported. The operating system should try to use window server 2012 R2 and above . If installed under win10, many permission problems may occur. Among them, the three software in red will be installed automatically during the installation of onlyoffice-documentserver.exe. The premise is that when the Windows server cannot connect to the external network, these software need to be installed in advance. Cerbot must be installed . The win32 version , the versions after 1.24 on github are all win64.

2. Installation process

  • Just click Next to install Erlang and RabbitMQ. They are installed on the C drive by default. You can modify the installation path.

  • When PostgreSQL is installed, you will be asked to set a database password. Remember this as it will be used later. The default port of the PostgreSQL database is 5432. If you want to modify the port, you will also need to modify the onlyoffice configuration file later. Try to use the default port. The database defaults It is installed on the C drive. If you want to modify the installation path of the database, you need to create a folder in advance and set the current account to full control.

  • After the PostgreSQL installation is completed, you need to set the role\group and database for onlyoffice. Run the installation directory\pgAdmin 4\bin\pgAdmin4.exe. After opening it, enter the database password you just set, and then create the group:

  • Switch to the "Definition" tab and enter onlyoffice in the "Password" field.

  • Go to the "Privileges" tab and check "Can login?"

  • Then click Save.

  • Then create an onlyoffice database, the owner selects the onlyoffice just created, and then saves it.

  • Or you can use commands to create groups and databases. Open the command window under "PostgreSQL installation directory\bin" and execute the following commands respectively.

  • psql -U postgres -c "CREATE USER onlyoffice WITH PASSWORD 'onlyoffice';"
    
  • psql -U postgres -c "CREATE DATABASE onlyoffice OWNER onlyoffice;"
    
  • After onlyoffice-documentserver is installed, it will occupy port 80 by default, so you need to specify the port during installation. Open the command window under the installation package path and enter: . During the installation process, you will be prompted onlyoffice-documentserver.exe /DS_PORT=端口号which dependencies need to be downloaded. If cerbot has been installed, you can remove cerbot. If you don't have an external network and need to download other dependencies, please install them yourself. If you want to modify the installation directory during the installation process, you also need to set the permissions of the folder to full control of the current account after the installation is completed, otherwise you will not be able to modify the configuration file. Then click Next and the installation is complete.

3. Configuration after installation is completed

After the installation is completed, access the port number address when starting the installation and the following page will appear:
Insert image description here
Click GO TO TEST EXAMPLE and the following page will appear.
Insert image description here
This is because the service of the official example page is not turned on.
We open the task manager on the server and find the following four services in the services.
Insert image description here
These are the four services related to onlyoffice. At this time the example service is closed. The example service will occupy port 3000. Please check whether port 3000 is occupied before opening it.
After the service is opened and accessed again, the following interface should appear, where you can create and edit documents using official cases.
Insert image description here
There will be a docservice.exe process in the detailed information of the server's task manager. This process will occupy port 8000. If
Insert image description here
this port is occupied, the document cannot be opened.
In the onlyoffice installation directory, the following folders may be modified
Insert image description here

3.1 Port configuration

In the config folder, default.json and local.json are commonly used configuration files.
Insert image description here

3.1.1 docservice service configuration

Modify the following configurations in default.json and local.json

"services": {
    
    
    "CoAuthoring": {
    
    
        "server": {
    
    
            "port": 8000,//默认8000
            ...
        }
            ...
     }
    ...
}

After the modification is completed, you still need to modify http-common.conf
Insert image description here
to modify the following configurations

## docservice的端口
upstream docservice {  
  server localhost:8000 max_fails=0 fail_timeout=0s;
}
## example服务的端口
upstream example {  
  server localhost:3000;
}

After the modification is completed and saved, restart the four major services of onlyoffice in the task manager.

3.1.2 Document server site port modification

Or nginx folder
Insert image description here

include includes/http-common.conf;
## 默认占用80端口
server {
  listen 0.0.0.0:80;
  listen [::]:80 default_server;
  server_tokens off;
  
  set $secure_link_secret OphIwQpJulSumDiLVL4l;
  include includes/ds-*.conf;
}

After the modification is completed and saved, restart the four major services of onlyoffice in the task manager.

3.2 Install fonts

When onlyoffice is installed, it will read the server's font files by default. If you need to add new fonts, please install the required fonts on the server now, and then run documentserver-generate-allfonts.bat in the bin directory. After executing this batch file, it will
Insert image description here
automatically Restart the relevant services, and then manually clear the client browser cache.

3.3 Modify font size

In Microsoft Office word or WPS text, we can see that the font sizes have the first number, the first number, the second number, etc., which are not available in onlyoffice. Find app.js in the path as shown in the figure and find {value:8,
Insert image description here
displayValue :"8"}, there should be three positions, and then paste the following content in front of these positions.

{
    
    value:42,displayValue:"初号"},{
    
    value:36,displayValue:"小初"},{
    
    value:26,displayValue:"一号"},{
    
    value:24,displayValue:"小一"},{
    
    value:22,displayValue:"二号"},{
    
    value:18,displayValue:"小二"},{
    
    value:16,displayValue:"三号"},{
    
    value:15,displayValue:"小三"},{
    
    value:14,displayValue:"四号"},{
    
    value:12,displayValue:"小四"},{
    
    value:10.5,displayValue:"五号"},{
    
    value:9,displayValue:"小五"},{
    
    value:7.5,displayValue:"六号"},{
    
    value:6.5,displayValue:"小六"},{
    
    value:5.5,displayValue:"七号"},{
    
    value:5,displayValue:"八号"},

After saving the modifications, restart the service, and then manually clear the client browser cache.

3.4 Other configurations

If you want to modify other content in the editor, please study the source code in web-apps yourself, such as modifying css styles.

4. Things to note when calling interfaces

4.1 Introduction

If you want to use the document server in your project, you can refer to the official access documentation . There are access methods for the three major front-end frameworks, Angular, React, and Vue.

You can also use script to introduce it directly, where documentserver is the address of the document server.

<script src="http://documentserver/web-apps/apps/api/documents/api.js"></script>

Note: The official Angular access method must be at least Angular 14.2 version. A version that is too low will not work.

My angular project here is introduced directly using script in index.html

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>onlyoffice</title>
  <base href="/" id="BasePath">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
  <script src="http://documentserver/web-apps/apps/api/documents/api.js"></script>
</head>
<body>
  <app-root></app-root>
</body>
</html>

4.2 Call

Please refer to the official documentation when calling the interface . I will only explain a few points that need to be paid attention to:

About key

The key in the document refers to the unique identifier of the document you are currently opening. In order to ensure that the document you open is new every time, it needs to be randomly generated every time you open it.

About token

The token in the document refers to the jwt encrypted string, which needs to be generated by calling the back-end interface. PayloadClaims is the front-end configuration object that generates the document editor, as shown below:

{
    
    
    "document": {
    
    
        "key": "Khirz6zTPdfd7",
        "permissions": {
    
    
            "comment": true,
            "commentGroups": {
    
    
                "edit": ["Group2", ""],
                "remove": [""],
                "view": ""
            },
            "copy": true,
            "deleteCommentAuthorOnly": false,
            "download": true,
            "edit": true,
            "editCommentAuthorOnly": false,
            "fillForms": true,
            "modifyContentControl": true,
            "modifyFilter": true,
            "print": true,
            "review": true,
            "reviewGroups": ["Group1", "Group2", ""]
        },
        "url": "https://example.com/url-to-example-document.docx"
    },
    "editorConfig": {
    
    
        "callbackUrl": "https://example.com/url-to-callback.ashx",
        "mode": "edit",
        "user": {
    
    
            "group": "Group1",
            "id": "78e1e841",
            "name": "Smith"
        }
    }
}

Java interface example: tokenSecret is the secret in the local.json file

public String createToken(final Map<String, Object> payloadClaims) {
    
    
        try {
    
    
            // build a HMAC signer using a SHA-256 hash
            Signer signer = HMACSigner.newSHA256Signer(tokenSecret);
            JWT jwt = new JWT();
            for (String key : payloadClaims.keySet()) {
    
      // run through all the keys from the payload
                jwt.addClaim(key, payloadClaims.get(key));  // and write each claim to the jwt
            }
            return JWT.getEncoder().encode(jwt, signer);  // sign and encode the JWT to a JSON string representation
        } catch (Exception e) {
    
    
            return "";
        }
    }

If you do not want to use jwt tokens, you can change the browser in local.json to false

"token": {
    
    
        "enable": {
    
    
          "request": {
    
    
            "inbox": true,
            "outbox": true
          },
          "browser": true //将这个设置为false,就不会检查token了
        },
        "inbox": {
    
    
          "header": "Authorization"
        },
        "outbox": {
    
    
          "header": "Authorization"
        }
      },

Remember to restart the service after modification

About callbackUrl

This is a key parameter for file saving and modification, and this URL must be an IPv4 address. This callback URL will be called when the document is opened, forced saved, or closed, and needs to be connected to your backend.
There is a savetimeoutdelay parameter in the default.json file under the config folder. The default is 5000, which is 5 seconds. It means that the callbackUrl will be called 5 seconds after the document is closed. You can set this to 0 and the callback address will be called immediately after the document is closed. . Please refer to the official documentation for specific docking methods .
If there is a message that the file cannot be saved, please contact the administrator. Most of the reasons are because there is a problem with the callbackUrl. Check whether this address can enter the back-end program. If it cannot enter, it means that there is an error in the address or the back-end code is written incorrectly. This callback The address must return a"{\"error\":0}"

About url

This is the address where the document server accesses files in your business server, and it must also be an IPv4 address. After accessing this address, a file must be generated. For the type of file, refer to the official documentation.

Guess you like

Origin blog.csdn.net/qq_45099813/article/details/129838840