docker安装部署 onlyoffice的详细过程
0. 系统要求
*处理器 i5-10400f以上
内存 16 gb,最佳32g内存
硬盘 至少40 gb的可用空间
1:安装docker desktop
2:进入bios设置cpu的虚拟化
https://jingyan.baidu.com/article/ab0b56305f2882c15afa7dda.html
3:启动docker desktop
报错解决:https://blog.csdn.net/qq_39611230/article/details/108625840
3:cmd进入,使用命令安装onlyoffice
安装通用版:
docker pull hub.c.163.com/gongzh/onlyoffice:latest
运行
docker run -i -t -d -p 8702:80 hub.c.163.com/gongzh/onlyoffice
安装社区版本【免费】:
docker run -i -t -d -p 8703:80 --restart=always onlyoffice/documentserver
查看容器,输入docker ps ,
进入容器,docker exec -i -t e15 /bin/bash 【e15是容器id】
安装中文包,onlyoffice中文字体包,解压之后运行docker_run.sh
4:123.rar文件是编辑word的代码,onlyoffceexample是接受文件的代码
5:h5页面配置,【必须使用ip地址而不是localhost】
<!doctype html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title></title> </head> <body style="height:900px;"> <div id="placeholder" style="height:880px;"></div> <script type="text/javascript" src="http://192.168.1.140:8703/web-apps/apps/api/documents/api.js"></script> <script type="text/javascript"> var config = { "editorconfig": { "lang": "zh-cn", "mode": "edit", }, "document": { "filetype": "docx", "key": "khirzs6ztpdfd27", "title": "example document title.docx", "url": "http://192.168.1.140/1234.docx",//这里填写文档的url路径 }, "documenttype": "text", "lang": "zh-cn", }; var doceditor = new docsapi.doceditor("placeholder", config); </script> </body> </html >
6:存在的问题必须使用【社区版本】,一个是【中文字体】
7:关闭页面后,自动保存的回调.
body:{"key":"12nafe","status":2,"url":"http://192.168.1.140:8702/cache/files/12nafe_3573/output.docx/output.docx?md5=ig6ycb-dgh708fundt-tsg==&expires=1623199603&disposition=attachment&ooname=output.docx","changesurl":"http://192.168.1.140:8702/cache/files/12nafe_3573/changes.zip/changes.zip?md5=asezumipjs5a-17wxp7opa==&expires=1623199603&disposition=attachment&ooname=output.zip","history":{"serverversion":"5.1.3","changes":[{"created":"2021-06-09 00:16:31","user":{"id":"uid-1623197783691","name":"anonymous"}},{"created":"2021-06-09 00:16:43","user":{"id":"uid-1623197795750","name":"anonymous"}},{"created":"2021-06-09 00:24:48","user":{"id":"uid-1623198283436","name":"anonymous"}}]},"users":["uid-1623198283436"],"actions":[{"type":0,"userid":"uid-1623198542944"}],"lastsave":"2021-06-09t00:27:54.050z","notmodified":false}
8:文件接收关键代码【一般处理程序】
public void processrequest(httpcontext context) { string body; using (var reader = new streamreader(context.request.inputstream)) body = reader.readtoend(); var filedata = new javascriptserializer().deserialize<dictionary<string, object>>(body); if (filedata != null && filedata["status"].tostring() == "2") { var req = webrequest.create((string)filedata["url"]); string path_for_save = context.server.mappath("~/temp/") + datetime.now.tostring("yyyymmddhhmmss") + ".docx"; using (var stream = req.getresponse().getresponsestream()) using (var fs = file.open(path_for_save, filemode.create)) { var buffer = new byte[4096]; int readed; while ((readed = stream.read(buffer, 0, 4096)) != 0) fs.write(buffer, 0, readed); } } context.response.write("{\"error\":0}"); }
以上就是docker部署 onlyoffice的详细内容,更多关于docker部署 onlyoffice的资料请关注其它相关文章!