准备环境依赖
--------安装PostgreSQL并创建数据库
--------安装Nginx
--------安装Node.js
--------安装libstdc++6
--------安装Redis
--------安装RabbitMQ
--------Ubuntu18.04特殊安装项
安装与配置Onlyoffice Document Server
--------修改服务器默认端口
--------修改服务器默认端口
--------Ubuntu18.04的spellchecker重建
--------开启HTTPS
--------对接Nextcloud
--------对接Onlyoffice Community Server
--------中文乱码,安装微软雅黑字体
只有搭建这个服务器,才能让Nextcloud的Onlyoffice app具有在线浏览编辑文档的能力,onlyoffice社区版同理.
介绍:
Document Server是一个在线办公套件,包括用于文本,电子表格和演示文稿的查看器和编辑器,与Office Open XML格式完全兼容:.docx,.xlsx,.pptx,并实现实时协作编辑。
功能:
- Document Editor
- Spreadsheet Editor
- Presentation Editor
- Documents application for iOS
- Collaborative editing
- Hieroglyph support
- Support for all the popular formats: DOC, DOCX, TXT, ODT, RTF, ODP, EPUB, ODS, XLS, XLSX, CSV, PPTX, HTML
软硬件配置要求:
- CPU:dual core 2 GHz or better
- RAM:2 GB or more
- HDD:at least 40 GB of free space
- Additional Requirements:at least 2 GB of swap
- OS:64-bit Debian, Ubuntu or other compatible distribution with kernel version 3.13 or later
Additional Requirements:
- PostgreSQL: version 9.1 or later
- NGINX: version 1.3.13 or later
- Node.js: version 6.9.1 or later
- libstdc++6: version 4.8.4 or later
- Redis
- RabbitMQ
本文使用1C2G的Ubuntu16.04,(建议不要和nextcloud同一台服务器,如果是一台,注意替换端口),功能可以实现,但是速度并不理想不能用于生产环境,确实非常吃性能
准备环境依赖
官方参考: https://www.onlyoffice.com/download.aspx
https://helpcenter.onlyoffice.com/server/linux/document/linux-installation.aspx
安装PostgreSQL并创建数据库
官方参考: https://www.postgresql.org/download/linux/ubuntu/
可以直接
sudo apt-get install postgresql
也可以参照官方如下,版本比较新
创建/etc/apt/sources.list.d/pgdg.list
文件并在其中添加一行源
vi /etc/apt/sources.list.d/pgdg.list
#添加如下
deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main
导入存储库签名密钥,并更新源
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
安装
apt-get install postgresql-10
安装完后配置数据库,数据库和用户名为“onlyoffice”(不可修改),密码为“onlyoffice”(可以修改成你自己的)
sudo -i -u postgres psql -c "CREATE DATABASE onlyoffice;"
sudo -i -u postgres psql -c "CREATE USER onlyoffice WITH password 'onlyoffice';"
sudo -i -u postgres psql -c "GRANT ALL privileges ON DATABASE onlyoffice TO onlyoffice;"
安装Nginx
apt-get install nginx
Ubuntu安装之后的文件结构大致为:
- 所有的配置文件都在/etc/nginx下,并且每个虚拟主机已经安排在了/etc/nginx/sites-available下
- 程序文件在/usr/sbin/nginx
- 日志放在了/var/log/nginx中
- 并已经在/etc/init.d/下创建了启动脚本nginx
- 默认的虚拟主机的目录设置在了/var/www/nginx-default (有的版本 默认的虚拟主机的目录设置在了/var/www, 请参考/etc/nginx/sites-available里的配置)
安装Node.js
官方文档: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
我安装了6.x
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt-get install nodejs
8.x
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
10.x
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
安装libstdc++6
此项如果系统是ubunbtu16.04及以上则已经自带,否则参考
https://pkgs.org/download/libstdc++6
找到对应系统版本并安装
安装Redis
sudo apt-get install redis-server
安装RabbitMQ
sudo apt-get install rabbitmq-server
在14.04 LTS之前的Ubuntu分发可能需要安装一些其他依赖项。
Ubuntu18.04特殊安装项
Ubuntu 18.04将需要安装npm和nginx-extras
sudo apt-get install npm nginx-extras
安装与配置Onlyoffice Document Server
修改服务器默认端口
默认情况下,Document Server使用端口80侦听传入连接。从版本4.3开始,你可以使用其他端口代替
如果你要修改端口,请注意端口冲突,这些是需要注意的开启或关闭的端口https://helpcenter.onlyoffice.com/server/docker/document/open-ports.aspx
注意:如果你想改为443以开启https,请不要这么做,下面会有添加https的方法,如果要使用https则这部不需要操作,使用默认80即可
运行以下以修改端口:
echo onlyoffice-documentserver onlyoffice/ds-port select <PORT_NUMBER> | sudo debconf-set-selections
举例:改为9000端口
echo onlyoffice-documentserver onlyoffice/ds-port select 9000 | sudo debconf-set-selections
安装Document Server
如果同时有Apache等占用80端口的运行程序,请先关闭
添加GPG key
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys CB2DE8E5
添加源
sudo echo "deb http://download.onlyoffice.com/repo/debian squeeze main" | sudo tee /etc/apt/sources.list.d/onlyoffice.list
更新源
sudo apt-get update
安装
sudo apt-get install onlyoffice-documentserver
注意:安装过程中会要求提供PostgreSQL的密码
安装完成,通过ip直接访问就可以看到绿色对号了.如果不要求https,现在就可以使用API去对接程序了
相关参考 http://api.onlyoffice.com/editors/basic
Ubuntu18.04的spellchecker重建
如果想让拼写检查器在Ubuntu18.04正常运行,需要以下操作
1.更新npm
sudo npm install -g npm
2.停止Document Server服务
sudo supervisorctl stop all
3.安装构建所需的组件
sudo apt-get install build-essential git
4.切换到拼写检查文件夹
cd /var/www/onlyoffice/documentserver/server/SpellChecker/
5.删除旧版本
sudo mv node_modules/ node_modules_old/
6.安装依赖
sudo npm install
7.最后重新启动Document Server服务
sudo supervisorctl start all
开启HTTPS
官方参考:https://helpcenter.onlyoffice.com/server/linux/document/switch-to-https.aspx
准备好证书和密钥文件
停止Nginx
service nginx stop
使用以下命令将onlyoffice-documentserver-ssl.conf.template
文件复制到onlyoffice-documentserver.conf
文件(前者没有请用locate
命令)
Debian系系统
sudo cp -f /etc/nginx/conf.d/onlyoffice-documentserver-ssl.conf.template /etc/nginx/conf.d/onlyoffice-documentserver.conf
CentOS系系统
sudo cp -f /etc/onlyoffice/documentserver/nginx/onlyoffice-documentserver-ssl.conf.template /etc/nginx/conf.d/onlyoffice-documentserver.conf
编辑Nginx配置文件
vi etc/nginx/conf.d/onlyoffice-documentserver.conf
将前两个和80相关的server{}
段用#
注释掉
如果之前改过端口,则修改两个listen
后面的:
后面的端口号{{SSL_CERTIFICATE_PATH}}
指向证书位置{{SSL_KEY_PATH}}
指向密钥位置
然后重启nginx
sudo service nginx start
如果报错,多半是密钥问题,注意位置,密钥内容
最后访问https://域名 可以看到绿色对号
我的配置文件如下
include /etc/nginx/includes/onlyoffice-http.conf;
## Normal HTTP host
#server {
# listen 0.0.0.0:80;
# listen [::]:80 default_server;
# server_name _;
# 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://$host$request_uri? permanent;
#}
#HTTP host for internal services
#server {
# listen 127.0.0.1:80;
# listen [::1]:80;
# server_name localhost;
# server_tokens off;
# include /etc/nginx/includes/onlyoffice-documentserver-common.conf;
# include /etc/nginx/includes/onlyoffice-documentserver-docservice.conf;
#}
## HTTPS host
server {
listen 0.0.0.0:443 ssl;
listen [::]:443 ssl default_server;
server_tokens off;
root /usr/share/nginx/html;
## Strong SSL Security
## https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
ssl on;
ssl_certificate /fullchain.crt;
ssl_certificate_key /joooe.xyz.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;
}
对接Nextcloud
进入nextcloud,点击右上角头像-应用
在左边栏下方Office & text
中找到Onlyoffice
并开启
点击右上角头像-设置-Onlyoffice(左边栏下方)Document Editing Service address
填写服务器的域名如https://office.domain.com
点击save
即可
对接Onlyoffice Community Server
https://www.youtube.com/watch?v=C6otRjpLFVA
进入文档设置,将每个输入框下面的示例复制到框中,然后将<editors-dns-name>
更改为域名,ip或内网ip,总之要对应document server的各个api文件.
中文乱码,安装微软雅黑字体
下载字体http://font.chinaz.com/940144340.htm
解压得到.tff
文件,将其上传到/usr/share/fonts/
导入字体
sudo bash documentserver-generate-allfonts.sh
注意清楚浏览器缓存才能生效
在编辑文档时,字体中就会有Microsoft Yahei,统里可以添加其他字体
-
版权声明:本文为原创文章,版权归Joe所有,转载请注明出处.
本文链接:https://www.j000e.com/linux/onlyofficedocumentserver.html
本作品采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可。