CentOS7上部署onlyoffice服务

onlyoffice

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

功能

  • 文件编辑器
  • 电子表格编辑器
  • 演示文稿编辑器
  • 移动网络查看器
  • 协同编辑
  • 象形文字支持
  • 支持所有流行格式:DOC、DOCX、TXT、ODT、RTF、ODP、EPUB、ODS、XLS、XLSX、CSV、PPTX、HTML

开始

安装最新的 Nginx 包版本

要为 RHEL/CentOS 设置 yum 存储库,创建vim /etc/yum.repos.d/nginx.repo,然后输入以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key

[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key

保存退出后,开始安装 Nginx

1
sudo yum install nginx -y

安装好之后,vim /etc/nginx/nginx.conf,应该是长这样的:

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 存储库

1
sudo yum install epel-release -y

安装和配置 PostgreSQL

安装 PostgreSQL:

1
sudo yum install postgresql postgresql-server -y

初始化 PostgreSQL 数据库:

1
2
sudo service postgresql initdb 
sudo chkconfig postgresql on

为 IPv4 和 IPv6 设置信任:

vim /var/lib/pgsql/data/pg_hba.conf之后,做出如下修改:

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

保存并退出,然后重启 PostgreSQL 服务

1
sudo service postgresql restart

创建 PostgreSQL 数据库和用户

先进入这个目录cd /tmp

然后创建数据库和用户:

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;"

安装RabbitMQ

1
sudo yum install rabbitmq-server -y

启动服务并设置开机自启:

1
2
sudo service rabbitmq-server start
sudo systemctl enable rabbitmq-server

安装 mscorefonts

安装cabextractxorg-x11-font-utils包:

1
2
sudo yum install cabextract xorg-x11-font-utils -y
sudo yum install fontconfig -y

安装 msttcore 字体包:

1
sudo rpm -i https://deac-ams.dl.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm

添加 ONLYOFFICE 文档存储库

1
sudo yum install https://download.onlyoffice.com/repo/centos/main/noarch/onlyoffice-repo.noarch.rpm

安装 ONLYOFFICE 文档

1
sudo yum install onlyoffice-documentserver -y

启动并设置开机自启:

1
2
3
4
sudo service supervisord start
sudo systemctl enable supervisord
sudo service nginx start
sudo systemctl enable nginx

运行配置脚本

运行documentserver-configure.sh脚本:

1
bash documentserver-configure.sh

然后输入下列数据:

PostgreSQL

1
2
3
4
Host: localhost
Database: onlyoffice
User: onlyoffice
Password: onlyoffice

RabbitMQ

1
2
3
Host: localhost
User: guest
Password: guest

添加至防火墙

1
2
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --reload

至此已经全部配置完毕,重启服务器,输入http://localhost,看到欢迎界面说明配置成功!

welcome

onlyoffice集成到nextcloud

下载onlyoffice

进入nextcloud应用商店,下载并启用onlyoffice

下载onlyoffice

然后进入设置进行配置

设置

坑!!!

如果报错Error when trying to connect (Host violates local access rules),那么配置文件记得加上
'allow_local_remote_servers' => true,