安装Docker

安装

# 安装必要依赖
yum install -y yum-utils device-mapper-persistent-data lvm2 # 添加aliyum docker-ce yum源
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo # 重建yum缓存
yum makecache # 安装指定版本docker,版本19.03.12
yum install -y docker-ce-19.03.12-3.el7 # 确保网络模块开机自动加载
lsmod | grep overlay
lsmod | grep br_netfilter cat > /etc/modules-load.d/docker.conf <<EOF
overlay
br_netfilter
EOF modprobe overlay
modprobe br_netfilter # 使桥接流量对iptables可见
cat > /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF sysctl --system # 验证是否生效,下面两个命令结果需均返回 1
sysctl -n net.bridge.bridge-nf-call-iptables
sysctl -n net.bridge.bridge-nf-call-ip6tables

配置Docker

# 创建docker镜像存储目录
cd ~
mkdir data
cd data/
mkdir docker
cd docker/
mkdir data-root
cd data-root/
pwd #输出结果:/root/data/docker/data-root # 创建docker配置文件目录
mkdir /etc/docker # 修改cgroup驱动为systemd[k8s官方推荐]、限制容器日志量、修改存储类型,最后的docker根目录可修改
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2",
"storage-opts": [
"overlay2.override_kernel_check=true"
],
"registry-mirrors": ["https://7uuu3esz.mirror.aliyuncs.com"],
"data-root": "/root/data/docker/data-root"
}
EOF # 添加开机自启动,并立即启动
systemctl enable --now docker

验证docker是否正常

# 查看docker信息,判断是否与配置一致
docker info # hello-docker测试
docker run --rm hello-world # 删除测试的image
docker rmi hello-world

验证能否通过IP:Port方式访问Docker站点

# 查看docker server信息,确认最后一行是否报错
docker info # 错误信息见下面最后一行,目前无错误信息
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Build with BuildKit (Docker Inc., v0.5.1-docker) Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.12
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: systemd
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e
runc version: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-1127.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.777GiB
Name: localhost.localdomain
ID: 2HIV:6EH2:KI53:BUGY:YD72:Q3BI:Y4MJ:X65V:YF2N:TFUZ:BRTD:ZOA3
Docker Root Dir: /root/data/docker/data-root
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://7uuu3esz.mirror.aliyuncs.com/
Live Restore Enabled: false

安装only-office server

参考地址:https://helpcenter.onlyoffice.com/installation/docs-community-install-docker.aspx?_ga=2.248226951.1825569553.1616058768-1266077697.1607495094

系统需求

  • CPU: dual core 2 GHz or better
  • RAM: 2 GB or more
  • HDD: at least 40 GB of free space
  • Additional requirements: at least 4 GB of swap
  • OS: amd64 Linux distribution with kernel version 3.10 or later
  • Additional requirements
    • Docker: version 1.10 or later

创建数据目录

  • /var/log/onlyoffice for ONLYOFFICE Docs logs
  • /var/www/onlyoffice/Data for certificates
  • /var/lib/onlyoffice for file cache
  • /var/lib/postgresql for database
# 进入数据存储目录
cd /root/data
mkdir onlyoffice
cd onlyoffice
mkdir DocumentServer
cd DocumentServer
pwd
# 显示路径:/root/data/onlyoffice/DocumentServer # 创建对应目录
mkdir logs
mkdir data
mkdir lib
mkdir db
ls

启动docker容器

# 启动docker容器,默认启动端口为80,可以进行修改
docker run -i -t -d -e TZ="Asia/Shanghai" -p 81:80 --restart=always \
-v /root/data/onlyoffice/DocumentServer/logs:/var/log/onlyoffice \
-v /root/data/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data \
-v /root/data/onlyoffice/DocumentServer/lib:/var/lib/onlyoffice \
-v /root/data/onlyoffice/DocumentServer/db:/var/lib/postgresql onlyoffice/documentserver # 查看镜像下载
docker images # 查看容器
docker ps # 查看启动日志
docker logs -f 容器ID

开放防火墙端口

# 开放端口
firewall-cmd --add-port=81/tcp --permanent # 重新加载配置
firewall-cmd --reload # 查看防火墙开放情况
firewall-cmd --list-port # 验证外网是否可以访问,查看此文件能否查看或打开
http://192.168.110.129:81/

可配置的参数

Please refer the docker run command options for the --env-file flag where you can specify all required environment variables in a single file. This will save you from writing a potentially long docker run command.

  • ONLYOFFICE_HTTPS_HSTS_ENABLED: Advanced configuration option for turning off the HSTS configuration. Applicable only when SSL is in use. Defaults to true.
  • ONLYOFFICE_HTTPS_HSTS_MAXAGE: Advanced configuration option for setting the HSTS max-age in the onlyoffice NGINX vHost configuration. Applicable only when SSL is in use. Defaults to 31536000.
  • SSL_CERTIFICATE_PATH: The path to the SSL certificate to use. Defaults to /var/www/onlyoffice/Data/certs/onlyoffice.crt.
  • SSL_KEY_PATH: The path to the SSL certificate private key. Defaults to /var/www/onlyoffice/Data/certs/onlyoffice.key.
  • SSL_DHPARAM_PATH: The path to the Diffie-Hellman parameter. Defaults to /var/www/onlyoffice/Data/certs/dhparam.pem.
  • SSL_VERIFY_CLIENT: Enable verification of client certificates using the CA_CERTIFICATES_PATH file. Defaults to false.
  • POSTGRESQL_SERVER_HOST: The IP address or the name of the host where the PostgreSQL server is running.
  • POSTGRESQL_SERVER_PORT: The PostgreSQL server port number.
  • POSTGRESQL_SERVER_DB_NAME: The name of a PostgreSQL database to be created on the image startup.
  • POSTGRESQL_SERVER_USER: The new user name with superuser permissions for the PostgreSQL account.
  • POSTGRESQL_SERVER_PASS: The password set for the PostgreSQL account.
  • AMQP_SERVER_URL: The AMQP URL to connect to the message broker server.
  • AMQP_SERVER_TYPE: The message broker type. Supported values are rabbitmq or activemq. Defaults to rabbitmq.
  • REDIS_SERVER_HOST: The IP address or the name of the host where the Redis server is running.
  • REDIS_SERVER_PORT: The Redis server port number.
  • NGINX_WORKER_PROCESSES: Defines the number of NGINX worker processes.
  • NGINX_WORKER_CONNECTIONS: Sets the maximum number of simultaneous connections that can be opened by a NGINX worker process.
  • JWT_ENABLED: Specifies the enabling the JSON web token validation by ONLYOFFICE Docs. Defaults to false.
  • JWT_SECRET: Defines the secret key to validate the JSON web token in the request to ONLYOFFICE Docs. Defaults to secret.
  • JWT_HEADER: Defines the HTTP header that will be used to send the JSON web token. Defaults to Authorization.

使用文档

官方文档地址:https://api.onlyoffice.com/editors/basic.

添加中文字体

编辑字体

  • 在Windows目录的C:\Windows\Fonts查找常用中文字体文件;
  • 使用字体编辑软件FontCreator修改参数配置:
    • 选择 字体属性;
    • 将字体家族改为中文;

      字体子族改为常规;

      注意:这里字体家族中间得加个空格。
  • 将修改后的字体导出为新的字体包。

删除自带字体

# 进入容器内
docker ps
docker exec -it 51 bash # 删除原版自带字体
cd /usr/share/fonts/
rm -rf * cd /var/www/onlyoffice/documentserver/core-fonts/
rm -rf *

将字体文件导入docker容器,此种方式设置后字体生效,但是字体选择列表中中文字体显示乱码

# 在服务器创建字体目录
cd /root/data/onlyoffice
mkdir fonts
cd fonts/ # 将字符文件复制到该目录
rz # 将字体复制到容器的对应目录下
docker cp /root/data/onlyoffice/fonts/ 51e38c77ddbd:/usr/share/fonts/truetype/custom docker cp /root/data/onlyoffice/dockerImage/Contents.json e13c3a79dc43:/var/www/onlyoffice/documentserver/web-apps/apps/documenteditor/main/resources/help/zh # 进入容器内
docker ps
docker exec -it 51 bash # 确认字体文件是否是最新的
cd /usr/share/fonts/truetype/custom/fonts
ll # 执行字体重新加载脚本
cd /usr/bin/
./documentserver-generate-allfonts.sh # 输出内容如下:
Generating AllFonts.js, please wait...Done
Generating presentation themes, please wait...Done
ds:docservice: stopped
ds:docservice: started
ds:converter: stopped
ds:converter: started # 生成的字体JS配置文件
/var/www/onlyoffice/documentserver/server/FileConverter/bin/AllFonts.js

文件预览

创建Html页面,在html文件中编写对应预览代码。

documentType参数说明

# 5.4.2 版本
# 字符串类型,定义文档打开类型: 1、text(.doc, .docm, .docx, .dot, .dotm, .dotx, .epub, .fodt, .htm, .html, .mht, .odt, .ott, .pdf, .rtf, .txt, .djvu, .xps); 2、spreadsheet(.csv, .fods, .ods, .ots, .xls, .xlsm, .xlsx, .xlt, .xltm, .xltx); 3、presentation(.fodp, .odp, .otp, .pot, .potm, .potx, .pps, .ppsm, .ppsx, .ppt, .pptm, .pptx).

World

<!DOCTYPE html>
<html style="height: 100%;">
<head>
<title>ONLYOFFICE Word</title>
<link rel="icon" href="https://oa.cnki.net/v/home/cnki.ico" type="image/x-icon" />
<link rel="shortcut icon" href="https://oa.cnki.net/v/home/cnki.ico" type="image/x-icon" />
</head>
<body style="height: 100%; margin: 0;">
<div id="placeholder" style="height: 100%"></div>
<script type="text/javascript" src="http://192.168.110.129:81/web-apps/apps/api/documents/api.js"></script> <script type="text/javascript"> window.docEditor = new DocsAPI.DocEditor("placeholder",
{
"document": {
"fileType": "docx",
"key": "D24A86BDE9A2-01-10",
"permissions": {
"comment": false,
"copy": true,
"download": true,
"edit": false,
"fillForms": false,
"modifyContentControl": false,
"modifyFilter": true,
"print": true,
"review": false
},
"title": "test.docx",
"url": "http://192.168.110.129/onlyoffice/word01.docx"
},
"documentType": "word",
"editorConfig": {
"mode": "view",
"lang": "zh-CN",
"customization": {
"chat": false,
"comments": false,
"compactHeader": false,
"compactToolbar": false,
"compatibleFeatures": false,
"customer": {
"address": "北京",
"info": "中国知网",
"logo": "https://oa.cnki.net/v/home/cnki.ico",
"mail": "oa@cnki.net",
"name": "中国知网",
"www": "https://oa.cnki.net"
},
"feedback": {
"url": "https://oa.cnki.net",
"visible": false
},
"help": false,
"hideRightMenu": true,
"logo": {
"image": "https://oa.cnki.net/v/home/cnki.ico",
"imageEmbedded": "https://oa.cnki.net/v/home/cnki.ico",
"url": "https://oa.cnki.net"
},
"plugins": false,
"toolbarHideFileName": true
}
},
"type": "desktop",
"height": "100%",
"width": "100%"
}); </script>
</body>
</html>

Excel

<!DOCTYPE html>
<html style="height: 100%;">
<head>
<title>ONLYOFFICE Excel</title>
</head>
<body style="height: 100%; margin: 0;">
<div id="placeholder" style="height: 100%"></div>
<script type="text/javascript" src="http://10.120.160.113:81/web-apps/apps/api/documents/api.js"></script> <script type="text/javascript"> window.docEditor = new DocsAPI.DocEditor("placeholder",
{
"document": {
"fileType": "xlsx",
"key": "138E9734B413-01",
"title": "Example Spreadsheet Title.xlsx",
"url": "http://oa.cnki.net/api/file/File/Download?fileId=065F87CE9C724D2AA26313E449A59809" //"http://10.120.160.100/fs/test-onlyoffice/test01.xlsx"
},
"documentType": "cell",
"editorConfig": {
"mode": "view"
},
"height": "100%",
"width": "100%"
}); </script>
</body>
</html>

PPT

<!DOCTYPE html>
<html style="height: 100%;">
<head>
<title>ONLYOFFICE PPT</title>
</head>
<body style="height: 100%; margin: 0;">
<div id="placeholder" style="height: 100%"></div>
<script type="text/javascript" src="http://10.120.160.113:81/web-apps/apps/api/documents/api.js"></script> <script type="text/javascript"> window.docEditor = new DocsAPI.DocEditor("placeholder",
{
"document": {
"fileType": "pptx",
"key": "D24A86BDE9A2-01-03-123",
"title": "Example Presentation Title.pptx",
"url": "http://10.120.160.100/fs/test-onlyoffice/ppt01.pptx"
},
"documentType": "slide",
"editorConfig": {
"mode": "view"
},
"height": "100%",
"width": "100%"
}); </script>
</body>
</html>

测试预览URL

http://192.168.110.129/onlyoffice/index-word.html

http://192.168.110.129/onlyoffice/index-word-cnki.html

http://192.168.110.129/onlyoffice/index-excel.html

http://192.168.110.129/onlyoffice/index-ppt.html

文档下载接口测试:http://oa.cnki.net/api/file/File/Download?fileId=065F87CE9C724D2AA26313E449A59809

文件编辑

下面以word文件编辑作为示例进行验证。

在文档编辑时,需指定编辑的回调地址,此回调程序使用Java语言编写,以jar包方式在服务器上面运行,因此需要在服务器上面安装JDK环境。

<!DOCTYPE html>
<html style="height: 100%;">
<head>
<title>ONLYOFFICE Api Documentation</title>
</head>
<body style="height: 100%; margin: 0;">
<div id="placeholder" style="height: 100%"></div>
<script type="text/javascript" src="http://192.168.110.129:82/web-apps/apps/api/documents/api.js"></script> <script type="text/javascript"> window.docEditor = new DocsAPI.DocEditor("placeholder",
{
"document": {
"fileType": "docx",
"key": "E7FAFC9C2210-020",
"title": "word01.docx",
"url": "http://192.168.110.129/onlyoffice/word01.docx"
},
"documentType": "text",
"editorConfig": {
"lang": "zh-cn",
"callbackUrl": "http://192.168.110.129:8080/test/getRequestData",
"customization": {
"chat": false,
"comments": false,
"compactHeader": false,
"compactToolbar": false,
"compatibleFeatures": false,
"customer": {
"address": "北京",
"info": "中国知网",
"logo": "https://oa.cnki.net/v/home/cnki.ico",
"mail": "oa@cnki.net",
"name": "中国知网",
"www": "https://oa.cnki.net"
},
"feedback": {
"url": "https://oa.cnki.net",
"visible": false
},
"help": false,
"hideRightMenu": true,
"logo": {
"image": "https://oa.cnki.net/v/home/cnki.ico",
"imageEmbedded": "https://oa.cnki.net/v/home/cnki.ico",
"url": "https://oa.cnki.net"
},
"plugins": false,
"toolbarHideFileName": true
}
},
"height": "100%",
"width": "100%"
}); </script>
</body>
</html>

测试编辑URL

# word
http://192.168.110.129/onlyoffice/edit-word.html http://192.168.110.129/onlyoffice/edit-word-cnki.html # 查看验证
http://192.168.110.129/onlyoffice/index-word.html # 协同编辑
http://192.168.110.129/onlyoffice/co-edit-01.html
http://192.168.110.129/onlyoffice/co-edit-02.html

回调样例数据

// 进入编辑
{
"actions" : [ {
"type" : 1,
"userid" : "uid-1617000391704"
} ],
"forcesavetype" : 0,
"key" : "E7FAFC9C22A8",
"status" : 1,
"users" : [ "uid-1617000391704" ]
} //////////////////////////////////////////////////////////////////////////////////////////////////////// // 关闭页面后,自动保存的回调
{
"actions" : [ {
"type" : 0,
"userid" : "uid-1617000391704"
} ],
"changesurl" : "http://192.168.110.129:81/cache/files/E7FAFC9C22A8_2529/changes.zip/changes.zip?md5=tOXiIFPV9i59huCMjv5iMg&expires=1617001678&disposition=attachment&filename=changes.zip",
"forcesavetype" : 0,
"history" : {
"changes" : [ {
"created" : "2021-03-29 06:46:57",
"user" : {
"id" : "uid-1617000391704",
"name" : "Anonymous"
}
} ],
"serverVersion" : "6.1.0"
},
"key" : "E7FAFC9C22A8",
"status" : 2,
"url" : "http://192.168.110.129:81/cache/files/E7FAFC9C22A8_2529/output.docx/output.docx?md5=ROMKlDaRuRgCBti99kZH2Q&expires=1617001678&disposition=attachment&filename=output.docx",
"users" : [ "uid-1617000391704" ]
}

only-office以Docker方式安装使用的更多相关文章

  1. Windows下VMware虚拟机使用Centos,Docker方式安装openstf的小坑

    今天使用docker方式安装openstf碰到了一小坑,坑了我半天.特此记录! docker方式安装stf就不说了,网上教程一大把. 但是... 安装完之后.进入web控制界面,手机连接的好好的.但硕 ...

  2. 在CentOS上通过Docker方式安装Redis

    在CentOS上通过Docker方式安装Redis 首先保证已经安装docker. 拖拽redis镜像 docker pull redis 启动redis docker run -p 6379:637 ...

  3. Linux上通过docker方式安装mysql

    centos版本信息: docker版本信息 mysql版本:5.7 1.docker方式安装 首先拉取mysql镜像:docker pull mysql:5.7     查看本地的mysql镜像 执 ...

  4. openresty——yum安装 配置 使用 错误处理 docker方式安装

    yum方式安装 wget https://openresty.org/package/centos/openresty.repo mv openresty.repo /etc/yum.repos.d/ ...

  5. docker方式安装zabbix

    这个示例展现了如何运行支持MySQL数据库的Zabbix server,基于Nginx web服务器运行Zabbix web接口,以及Zabbix Java gateway. 1. 启动一个空的MyS ...

  6. pipelinewise 学习一 docker方式安装

    pipelinewise 没有提供基于pip 包的模式进行安装,而且推荐使用docker 以及源码的方式 以下是一个使用docker运行的方式 安装   git clone https://githu ...

  7. Docker方式安装QIIME 2

    # 下载最新版QIIME 2 docker pull qiime2/core:2017.7 # 测试是否安装成功 docker run -t -i -v $(pwd):/mnt/hgfs/2017 q ...

  8. Docker方式安装Jenkins并且插件更改国内源

    参考网站:https://www.jenkins.io/zh/doc/book/installing/#在docker中下载并运行jenkins 建议使用的Docker映像是jenkinsci/blu ...

  9. 使用docker方式安装etcd集群,带TLS证书

    网上文档也多,安装的时候,还是踩了几个坑. 现在作一个安装记录吧. 1,先作自签名的证书ca-csr.json(为了和k8s共用根证书,可能将信息调为k8s). { "CN": & ...

  10. Jenkins - 以Docker方式安装启动Jenkins

    1 - 官网信息 操作步骤:https://jenkins.io/zh/doc/book/installing/#docker Docker映像地址:https://hub.docker.com/r/ ...

随机推荐

  1. Solon v2.2.10 发布,助力信创国产化

    Solon 是一个高效的 Java 应用开发框架:更快.更小.更简单.它不是 Spring.没有使用 Servlet.JavaEE 接口,是一个有自己接口标准的开放生态.可以为应用软件国产化提供支持, ...

  2. Claude:除ChatGPT外的另一种选择

    前言 Claude 是 Anthropic 开发的人工智能产品.Anthropic 是由 11 名前 OpenAI 员工于 2022 年创立的人工智能公司,旨在构建安全.可解释和有益于人类的人工智能系 ...

  3. NEQR: novel enhanced quantum representation

    一.概述   NEQR利用量子叠加和量子纠缠的特性,将数字图像转换为量子态表示,并通过量子门操作进行处理和操作.相较于传统的经典图像表示方法,NEQR具有更高的图像压缩率和更强的安全性,能够在保持图像 ...

  4. 【解决办法】配置banner信息时卡死/无反应,以及正确配置

    环境: 工具:锐捷EVE模拟器 远程工具:SecureCRT 系统版本:Windows 10 问题描述 描述:在配置登录 banner 提示警告信息时,将 "^" 符号放到了警告信 ...

  5. 解决VM虚拟机中IP或域名不能ping通

    c4548abb-da65-4f7d-827f-e95dca25a13d 问题 无法ping通域名, 检查事项 确定在同一个子网,能访问DNS服务器. DNS服务器正确设置了正反向解析,且DNS服务器 ...

  6. 一篇文章搞定什么是nodeJs它和NPM关系与应用

    现在前端的入门门槛越来越高了,不再是单纯 html+css+js,各种前端框架 层出不穷,各种ui组件库层出不穷. 模块化,打包化,各种工具库层出不穷,前端变成大前端 ,甚至前端可以搞定整个项目,通过 ...

  7. Go windows 环境搭建

    下载地址 官网下载地址:https://golang.google.cn/dl/ 1.下载完之后 双击msi进行安装 路径可以不用改, 继续next 安装完之后就需要配置环境变量, 找到环境变量 GO ...

  8. Python定时任务框架apscheduler的简单使用

    apscheduler的简单使用 APScheduler有四大组件: 1.触发器 triggers : 触发器包含调度逻辑.每个作业都有自己的触发器,用于确定下一个任务何时运行.除了初始配置之外,触发 ...

  9. Pillow模块——生成随机验证码

    urls.py path('get_code/',views.get_code), views.py中 from PIL import Image,ImageFont,ImageDraw " ...

  10. 2023-04-25:给定两个长度为N的数组,a[]和b[] 也就是对于每个位置i来说,有a[i]和b[i]两个属性 i a[i] b[i] j a[j] b[j] 现在想为了i,选一个最

    2023-04-25:给定两个长度为N的数组,a[]和b[] 也就是对于每个位置i来说,有a[i]和b[i]两个属性 i a[i] b[i] j a[j] b[j] 现在想为了i,选一个最好的j位置, ...