如何部署onlyOffice documentServer?

Linux基础

1 基础知识

1.1 onlyOffice的简介

– onlyOffice Document Server是一个在线办公套件
– onlyOffice Document Server可用于文本、电子表格和演示文稿的查看和编辑
– onlyOffice Document Server与Office Open XML格式完全兼容
– onlyOffice Document Server支持“.docx”、“.xlsx”、“.pptx”且支持实时协作编辑

1.2 onlyOffice的版本

– Community Edition (onlyoffice-documentserver package)
– Enterprise Edition (onlyoffice-documentserver-ee package)
– Developer Edition (onlyoffice-documentserver-de package)
注:onlyOffice Document Server从6.0版本开始拆分为三个版本

1.3 onlyOffice的功能

– 文件编辑器
– 电子表格编辑器
– 适用于IOS的应用程序
– 协同编辑
– 象形文字支持
– 支持所有主流格式DOC,DOCX,TXT,ODT,RTF,ODP,EPUB,ODS,XLS,XLSX,CSV,PPTX,HTML

1.4 onlyOffice的安装要求

– 内存:4 GB以上
– CPU:双核2 GHz或更高
– 交换:至少2 GB
– 硬盘:至少2 GB的可用空间
支持的系统发行版,
– Red Hat、CentOS x64
– Debian,Ubuntu x64
– 或与其他内核版本3.8或更高版本兼容的发行版
– Docker:1.9.0或更高版本

2 最佳实践

2.1 部署前的准备

hostname = onlyOffice.cmdschool.org
ip address = 10.168.0.81
os = centos 7.x x86_64
selinux = disable
epel = enable
open port= http https
具体请参阅以下文档完成,

如何完成CentOS 7.x的基本服务?

2.2 安装Nginx

2.2.1 安装软件包

yum install -y nginx

2.2.2 修改nginx配置

cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.defautl
vim /etc/nginx/nginx.conf

配置修改如下,

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
}

2.2.3 启动并设置服务自启动

systemctl start nginx.service
systemctl enable nginx.service

2.3 安装postgresql

2.2.1 安装软件包

yum install -y postgresql postgresql-server

2.2.2 初始化数据库

service postgresql initdb 

2.2.3 启动并配置服务自启动

systemctl start postgresql.service
systemctl enable postgresql.service

2.2.3 修改连接配置

cp /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf.default
vim /var/lib/pgsql/data/pg_hba.conf

修改如下配置,

host    all             all             127.0.0.1/32            trust
host    all             all             ::1/128                 trust

编辑完成后,需要使用如下命令重启使配置生效,

systemctl restart postgresql.service

2.2.4 创建应用所需的库

cd /tmp
sudo -u postgres psql -c "CREATE DATABASE onlyoffice;"
sudo -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyofficepwd';"
sudo -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"

另外,如果需要修改密码请使用如下命令,

sudo -u postgres psql -c "ALTER USER onlyoffice WITH password 'onlyofficepwd';"

2.4 安装RabbitMQ

2.4.1 安装软件包

yum install -y rabbitmq-server

2.4.2 启动并配置服务自启动

systemctl start rabbitmq-server.service
systemctl enable rabbitmq-server.service

另外,如果启动服务遇到如下错误提示,

Nov 29 17:50:48 onlyoffice rabbitmq-server: ERROR: epmd error for host onlyoffice: address (cannot connect to host/port)

意思是不能连接主机“onlyoffice”,则需要通过配置DNS或者主机名称解析解决,具体可使用如下命令

vim /etc/hosts

加入如下配置即可,

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4 onlyoffice
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 onlyoffice

2.5 安装ONLYOFFICE Docs

2.5.1 安装软件包

yum install -y https://download.onlyoffice.com/repo/centos/main/noarch/onlyoffice-repo.noarch.rpm
yum install -y onlyoffice-documentserver

2.5.2 启动并配置服务自启动

systemctl start supervisord.service
systemctl enable supervisord.service

2.5.3 配置应用

bash documentserver-configure.sh

向导如下,

Configuring database access...
Host: localhost
Database name: onlyoffice
User: onlyoffice
Password: onlyofficepwd
Trying to establish PostgreSQL connection... OK
Installing PostgreSQL database... OK
Configuring AMQP access...
Host: localhost
User: guest
Password: guest
Trying to establish AMQP connection... OK
Restarting services... OK

2.5.4 配置SSL

vim /etc/nginx/conf.d/ds.conf

加入如下配置,

server {
  listen 0.0.0.0:443 ssl;
  listen [::]:443 ssl default_server;
  server_tokens off;
  ssl_certificate 1_onlyoffice.cmdschool.org_bundle.crt;
  ssl_certificate_key 2_onlyoffice.cmdschool.org.key;
  ssl_session_timeout 5m;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
  ssl_prefer_server_ciphers on;

  include /etc/nginx/includes/ds-*.conf;
}

根据以上配置文件,你需要“onlyoffice.cmdschool.org”的nginx证书,你可以通过如下链接申请(证书请自行存于“/etc/nginx/”目录),
https://cloud.tencent.com/product/ssl
配置完成后,需要执行以下命令重载使配置生效,

systemctl reload nginx.service

另外,官方建议永久修改需要编辑以下文件,

cp /etc/onlyoffice/documentserver/nginx/ds-ssl.conf.tmpl /etc/onlyoffice/documentserver/nginx/ds-ssl.conf
vim /etc/onlyoffice/documentserver/nginx/ds-ssl.conf

2.5.5 设置防火墙

firewall-cmd --permanent --add-service https --add-service http
firewall-cmd --reload
firewall-cmd --list-all

2.5.6 测试服务的访问

https://onlyoffice.cmdschool.org/welcome/

另外,临时性的名称解析你可以按下键盘的【Win+R】键,然后输入如下命令,

notepad \Windows\System32\drivers\etc\hosts

然后加入如下配置,

10.168.0.81 onlyoffice.cmdschool.org

2.5.7 排错方法

tail -f /var/log/onlyoffice/documentserver/docservice/err.log
tail -f /var/log/onlyoffice/documentserver/docservice/out.log

参阅文档
===============

安装onlyoffice社区版本
————————-
https://helpcenter.onlyoffice.com/installation/docs-community-install-centos.aspx?_ga=2.128026956.1161075560.1606616066-378347967.1604794884

配置SSL
————–
https://helpcenter.onlyoffice.com/installation/docs-community-https-linux.aspx

官方主页
————————-
https://www.onlyoffice.com/zh/

没有评论

发表评论

Linux基础
如何熟悉TCP三次握手和四次挥手?

1 基础知识 1.1 基本概念 1.1.1 TCP握手 TCP客户端与服务端通过三次捂手建立TCP连 …

Linux基础
如何测试网络带宽?

1 前言 一个问题,一篇文章,一出故事。 笔者需要通过命令行测试出口的带宽,于是产生此文。 2 最佳 …

Linux基础
如何测试存储设备的读写IO速度?

1 前言 一个问题,一篇文章,一出故事。 笔者需要测试存储设备的读写IO速度,于是整理此文。 2 最 …