在CentOS和衍生产品上安装适用于Linux的Document Server(在线办公套件)
介绍
Document Server是一个在线办公套件,包括用于文本,电子表格和演示文稿的查看器和编辑器,与Office Open XML格式完全兼容:.docx,.xlsx,.pptx,并实现协作编辑。
功能
- 文档编辑器
- 电子表格编辑器
- 演示编辑器
- iOS的文档应用程序
- 协同编辑
- 象形文字的支持
- 支持所有流行格式:DOC,DOCX,TXT,ODT,RTF,ODP,EPUB,ODS,XLS,XLSX,CSV,PPTX,HTML
本指南将向您展示如何将Document Server Linux版本安装到您的计算机上。
系统要求
-
中央处理器双核2 GHz或更高
-
内存2 GB或更多
-
硬盘至少40 GB的可用空间
-
其他要求至少2 GB的掉期
-
OSRHEL 7或CentOS 7
-
其他要求
- PostgreSQL:9.1或更高版本
- NGINX:版本1.3.13或更高版本
- Node.js:版本8.12.0
- Redis的
- 的RabbitMQ
安装依赖项
添加包含最新Node.js包版本的存储库
添加存储库:
1 |
curl -sL https://rpm.nodesource.com/setup_8.x | sudo bash - |
安装最新的NGINX软件包版本
要为RHEL / CentOS设置yum存储库,请创建/etc/yum.repos.d/nginx.repo
使用以下内容命名的文件:
1 2 3 4 5 |
[nginx] name=nginx repo baseurl=http://nginx.org/packages/OS/7/$basearch/ gpgcheck=0 enabled=1 |
替换OS
为rhel
或centos
取决于使用的分布(官方说明)。
安装NGINX:
1 |
yum install nginx |
之后编辑/etc/nginx/nginx.conf
NGINX配置文件,使其看起来如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; 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; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; } |
安装EPEL存储库
yum install epel–release
安装和配置PostgreSQL
安装您的CentOS版本中包含的PostgreSQL版本:
1 |
yum install postgresql postgresql-server |
初始化PostgreSQL数据库
1 2 |
service postgresql initdb chkconfig postgresql on |
打开 IPv4和IPv6 localhost 的“信任”身份验证方法
/var/lib/pgsql/data/pg_hba.conf
在文本编辑器中打开文件。
找到该host all all 127.0.0.1/32 ident
字符串并将其替换为以下字符串:
1 |
host all all 127.0.0.1/32 trust |
然后找到该host all all ::1/128 ident
字符串并将其替换为以下字符串:
1 |
host all all ::1/128 trust |
保存更改。
重启PostgreSQL服务:
1 |
service postgresql restart |
创建PostgreSQL数据库和用户:
首先运行命令
1 |
cd /tmp |
could not change directory to "/root"
从root运行时阻止警告。然后必须创建数据库和用户:
1 2 3 |
sudo -u postgres psql -c "CREATE DATABASE onlyoffice;" sudo -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';" sudo -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;" |
安装Redis
1 |
yum install redis |
启动redis服务并启用启动时启动:
1 2 |
service redis start systemctl enable redis |
安装RabbitMQ
1 |
yum install rabbitmq-server |
启动rabbitmq服务并启动启动时启动:
1 2 |
service rabbitmq-server start systemctl enable rabbitmq-server |
安装文件服务器
添加文件服务器存储库
使用以下命令添加yum Document Server存储库:
1 |
yum install http://download.onlyoffice.com/repo/centos/main/noarch/onlyoffice-repo.noarch.rpm |
安装文件服务器
执行以下命令:
1 |
yum install onlyoffice-documentserver |
运行相关服务并在启动时启用它们:
1 2 3 4 |
service supervisord start systemctl enable supervisord service nginx start systemctl enable nginx |
之后,文档服务器将作为进程运行。该包将像任何其他rpm包一样更新。
现在,您可以使用提供的API将Document Server连接到社区服务器或将其集成到您自己的文档管理系统中。
更改默认文档服务器端口
默认情况下,Document Server使用端口80侦听传入连接。从版本4.3开始,如果您打算使用文档服务器而不是默认端口,则可以更改文件服务器的端口。
为此,您需要编辑运行该命令的DS_PORT环境变量:
1 |
export DS_PORT=<PORT_NUMBER> |
请写入端口号而不是<PORT_NUMBER>
上面的命令。
警告如果要将文件服务器协议更改为HTTPS,请不要将端口更改为443,而是使用此说明。
将Document Server v5.2及更高版本切换为HTTPS
在开始将文件服务器切换为HTTPS协议之前,您需要创建安全证书和证书私钥。将它们放入安装了Document Server的计算机上的文件夹中。
获得证书后,请继续执行以下步骤:
停止NGINX服务:
1 |
service nginx stop |
使用以下命令onlyoffice-documentserver-ssl.conf.template
将onlyoffice-documentserver.conf
文件复制到文件:
1 |
cp -f /etc/onlyoffice/documentserver/nginx/onlyoffice-documentserver-ssl.conf.template /etc/onlyoffice/documentserver/nginx/onlyoffice-documentserver.conf |
编辑/etc/onlyoffice/documentserver/nginx/onlyoffice-documentserver.conf
文件,更改实际使用的双花括号{{…}}中的所有参数:
- {{SSL_CERTIFICATE_PATH}} – 您获得的SSL证书的路径;
- {{SSL_KEY_PATH}} – SSL证书私钥的路径;
- {{SSL_VERIFY_CLIENT}} -客户端证书的验证是否被启用(具有可用值
on
,off
,optional
和optional_no_ca
); - {{CA_CERTIFICATES_PATH}} – 客户端证书的路径,如果使用上一个参数启用,将验证该路径;
- {{ONLYOFFICE_HTTPS_HSTS_MAXAGE}} – 高级配置选项,用于在文件服务器 NGINX vHost配置中设置HSTS max-age,仅在使用SSL时适用(通常默认为
31536000
足够安全); - {{SSL_DHPARAM_PATH}} – Diffie-Hellman参数的路径;
有关配置文件中使用的SSL参数的更多信息, 请参阅NGINX文档。
也可按如下配置进行修改:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
include /etc/nginx/includes/onlyoffice-http.conf; ## Normal HTTP host server { listen 0.0.0.0:80; listen [::]:80 default_server; server_name xxx.com ;#你的域名 server_tokens off; ## Redirects all traffic to the HTTPS host root /nowhere; ## root doesn't have to be a valid path since we are redirecting rewrite ^ https://xxx.com ;#你的域名 permanent; } #HTTP host for internal services server { listen 80; #listen [::]:80; server_name xxx.com ;#你的域名 server_tokens off; include /etc/nginx/includes/onlyoffice-documentserver-common.conf; include /etc/nginx/includes/onlyoffice-documentserver-docservice.conf; } ## HTTPS host server { listen 443 ssl http2; #listen [::]:443 ssl http2; server_name xxx.com ;#你的域名 root /usr/share/nginx/html; ## Strong SSL Security ## https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html ssl on; ssl_certificate /app/1778033_office.jgdtd.com.cer; ssl_certificate_key /app/1778033_office.jgdtd.com.key; ssl_verify_client off; ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH"; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_session_cache builtin:1000 shared:SSL:10m; ssl_prefer_server_ciphers on; add_header Strict-Transport-Security max-age=31536000; # add_header X-Frame-Options SAMEORIGIN; add_header X-Content-Type-Options nosniff; ## [Optional] If your certficate has OCSP, enable OCSP stapling to reduce the overhead and latency of running SSL. ## Replace with your ssl_trusted_certificate. For more info see: ## - https://medium.com/devops-programming/4445f4862461 ## - https://www.ruby-forum.com/topic/4419319 ## - https://www.digitalocean.com/community/tutorials/how-to-configure-ocsp-stapling-on-apache-and-nginx # ssl_stapling on; # ssl_stapling_verify on; # ssl_trusted_certificate /etc/nginx/ssl/stapling.trusted.crt; # resolver 208.67.222.222 208.67.222.220 valid=300s; # Can change to your DNS resolver if desired # resolver_timeout 10s; ## [Optional] Generate a stronger DHE parameter: ## cd /etc/ssl/certs ## sudo openssl dhparam -out dhparam.pem 4096 ## # ssl_dhparam /etc/ssl/certs/dhparam.pem; include /etc/nginx/includes/onlyoffice-documentserver-*.conf; } |
完成所有更改后,您可以再次启动NGINX服务:
1 |
service nginx start |
在nextcloud里面链接onloffice文件服务器时须在域名后面添加上端口号。否则会报错!!!