Centos7安装cloudreve+onlyoffice
1.安装onlyoffice
1.1 安装onlyoffice镜像
docker run -i -t -d -p 801:80 --restart=always -e JWT_ENABLED=false --name onlyoffice \
-v /home/xxx/important_onlyoffice/logs:/var/log/onlyoffice \
-v /home/xxx/important_onlyoffice/data:/var/www/onlyoffice/Data onlyoffice/documentserver
1.2 编辑view.html文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>预览</title>
</head>
<body>
<div id="placeholder"></div>
<script type="text/javascript" src="http://onlyoffice地址:onlyoffice端口/web-apps/apps/api/documents/api.js"></script>
<script>
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return decodeURIComponent(r[2]); return null;
}
//解码url
let url = GetQueryString("src")
var file= GetQueryString("name")
var suffix = file.split('.')
suffix=suffix[suffix.length-1]
var docEditor = new DocsAPI.DocEditor("placeholder", {
"document": {
"fileType": suffix,
"permissions": {
"edit": false,
"comment":true,
"download":true,
"print":true,
"fillForms": true,
},
"title": file,
"url": url,
},
"editorConfig":{
"callbackUrl": url, //回调地址,一定要保证docserver可以请求到,否则开不开文件
"lang":"zh-CN",
"mode":"view", //编辑模式 edit
},
"height": "1080px",
// "width": "100%",
"type":"desktop",
});
</script>
</body>
</html>
1.3 拷贝页面到docker下
docker cp view.html onlyoffice:/var/www/onlyoffice/documentserver-example/welcome
1.4 修改default.json文件
#从容器中拷贝出default.json文件
docker cp 58f75f6ca6f7:/etc/onlyoffice/documentserver/default.json ./
修改文件预览大小限制以及超时
#将default.json文件拷贝回容器中
docker cp default.json 58f75f6ca6f7:/etc/onlyoffice/documentserver/
#重启docker
docker restart 58f75f6ca6f7
2.安装cloudreve
2.1 docker安装cloudreve
#通过命令查找如下信息
id root
docker run -d \
--name cloudreve \
-e PUID=0 \
-e PGID=0 \
-e TZ="Asia/Shanghai" \
-p 5212:5212 \
--restart=always \
-v /home/preadmin/important_cloudreve/sharedfolders:/cloudreve/uploads \
-v /home/preadmin/important_cloudreve/dockercnf/cloudreve/config:/cloudreve/config \
-v /home/preadmin/important_cloudreve/dockercnf/cloudreve/db:/cloudreve/db \
-v /home/preadmin/important_cloudreve/dockercnf/cloudreve/avatar:/cloudreve/avatar \
cloudreve/cloudreve:3.8.0
2.2 (在cloudreve的管理面板-参数设置-图像预览的文件预览地址配置中将配置修改成onlyoffice的地址)
http://ip:port/welcome/view.html?src={$src}&name={$name}