1、准备镜像
准备一台可以联上外网的机器。依次下载镜像
$ docker pull nextcloud:24.0.4-apache
$ docker pull onlyoffice/documentserver
$ docker pull elastic_search:7.3.0
# 将elastic_search的ingest-attachment与IK分词插件提前安装好
$ docker run --name elas -itd elastic_search:7.3.0
$ docker exec -it elas /bin/bash
# 在docker内执行如下语句:
# 1) 安装ingest-attachment插件
$ /usr/share/elasticsearch/bin/elasticsearch-plugin install ingest-attachment
# 2)IK分词无法直接安装,需要指定下载地址
$ /usr/share/elasticsearch/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.3.0/elasticsearch-analysis-ik-7.3.0.zip
# 3) 安装完毕,退出docker
$ exit
# 保存新的安装了插件后的镜像
$ docker commit elas elastic_search730-ik:20230823
# 再将所有镜像保存为压缩文件
$ docker save -o nextcloud.tar nextcloud:24.0.4-apache
$ docker save -o documentserver.tar onlyoffice/documentserver
$ docker save -o elastic_search730-ik.tar elastic_search730-ik:20230823
将nextcloud.tar与documentserver.tar、elastic_search730-ik.tar上传到nextcloud服务器(192.168.53.197),并使用docker load命令装载之
说明:nextcloud版本号:24.0.4-apache
documentserver(Onlyoffice)版本:latest
elastic_search版本:7.3.0(已安装好ingest-attachment与IK分词插件elasticsearch-analysis-ik-7.3.0)
2、准备数据库
这边因为环境中已经有Mysql服务器,故不再以docker安装
找任一台Mysql服务器,登录之
sql>create database if not exists nextcloud default character set utf8 ;
Query OK, 1 row affected (0.01 sec)
mysql> grant all privileges on nextcloud.* to 'nextcloud'@'%' identified by 'XXXXX';
Query OK, 0 rows affected, 1 warning (0.01 sec)
3、启动nextcloud
$ docker run -itd --name nextcloud -v nextcloud:/var/www/html -p 8080:80 nextcloud:24.0.4-apache
4、配置nextcloud
5、登录nextcloud
再次访问http://192.168.53.197,以nextcloud/XXXX(你刚才配置的密码)登录之
6、安装 onlyoffice插件
先到插件下载地址 https://apps.nextcloud.com/
根据nextcloud版本选择相应onlyoffice插件,再将 onlyoffice.tar.gz上传到服务器
$ tar xvf onlyoffice.tar.gz
# 将解压后的插件复制到docker内apps目录
$ docker cp onlyoffice nextcloud:/var/www/html/apps
在页面上点击右上角图像--“应用”,再将右侧插件列表拉至最底下。找到ONLYOFFICE,启用之
7、启动documentserver
$ mkdir -p /app/onlyoffice
$ docker run -itd--restart=always --name onlyoffice-document-server \
-v /app/onlyoffice/DocumentServer/logs:/var/log/onlyoffice \
-v /app/onlyoffice/DocumentServer/data:/var/www/onlyoffice/Data \
-v /app/onlyoffice/DocumentServer/lib:/var/lib/onlyoffice \
-v /app/onlyoffice/DocumentServer/db:/var/lib/postgresql \
-p 8081:80 onlyoffice/documentserver
8、配置在线编辑
在网页中,右上角”图像“-”设置“-”ONLYOFFICE",填上documentserver地址:http://192.168.53.197:8081/
9、配置Redis缓存
环境中没有安装Redis的,可以自行下载一个镜像以docker安装
$ docker cp nextcloud:/var/www/html/config/config.php ./
$ vi config.php #在'memcache.local' => '\\OC\\Memcache\\APCu'后添加
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => '192.168.xxx.xxx', # 填你自己的真实ip
'timeout' => 0,
'dbindex' => 16,
'port' => 6379,
),
$ docker cp config.php nextcloud:/var/www/html/config/
$ docker exec -it nextcloud bash
$ chmod 777 /var/www/html/config/config.php
$ ctrl + d 退出docker
$ docker restart nextcloud
10、验证在线编辑功能
选择任一DOC文件打开,编辑
11、安装PC端
下载地址在https://nextcloud.com/install/#install-clients
PC端安装使用略
12、添加全文搜索
12.1 运行起镜像
$docker run -d -p 9200:9200 -p 9300:9300 -e ES_JAVA_POTS="-Xms128m -Xmx128m" -e "discovery.type=single-node" --name elastic_search elastic_search730-ik:20230823
12.2 安装三个插件并启用之
Full text search、Full text search - Elasticsearch Platform、Full text search - Files
方法同上步骤6
12.3 配置Elasticsearch
12.4 建立索引
$ docker exec -it nextcloud /bin/bash
# 进入nextcloud的docker 内
$ php ./occ fulltextsearch:check
Full text search 24.0.0
- Search Platform:
Elasticsearch 24.0.1 (Selected)
{
"elastic_host": [
"http://192.168.53.197:9200"
],
"elastic_index": "nextcloud",
"fields_limit": "10000",
"es_ver_below66": "0",
"analyzer_tokenizer": "ik_smart"
}
.....
# php ./occ fulltextsearch:test
.Testing your current setup:
Creating mocked content provider. ok
Testing mocked provider: get indexable documents. (2 items) ok
Loading search platform. (Elasticsearch) ok
Testing search platform. ok
Locking process ok
Removing test. ok ......
# php ./occ fulltextsearch:index # 新建索引
Options: []
Memory: 39 MB
┌─ Indexing ────
│ Action: indexDocument
│ Provider: Files Account: nextcloud
│ Document: 71
│ Info: application/vnd.oasis.opendocument.presentation
│ Title: 模板/Simple.odp
│ Content size: 19748
│ Chunk: 33/33
│ Progress: all/1
└──
┌─ Results ────
│ Result: 33/33
│ Index: files:71
│ Status: ok
│ Message: {"_index":"nextcloud","_type":"_doc","_id":"files:71","_version":1,"result":"created","_shards":{"total":2,"successful":1,"failed":0}
│ ,"_seq_no":39,"_primary_term":2}
│
└──
┌─ Errors ────
│ Error: 0/0
│ Index:
│ Exception:
│ Message:
│
│
└──
# 保持索引更新
php ./occ fulltextsearch:live -q
13、 文件备份
文件存放位置:/var/lib/docker/volumes/nextcloud/
可以配置一个crontab任务定时复制
14、日志文件位置
/var/lib/docker/volumes/nextcloud/_data/data/nextcloud.log
15、安装其他插件
如日历calendar、笔记notes、联系人contacts等
16、说明
- nextcloud24一定要配合Elasticsearch7使用,使用Elasticsearch8 创建索引时会提示“Elasticsearch no alive nodes found in cluster”或“ElasticSearchPlatform is not configured properly”错误
- nextcloud24docker内无法使用systemctl创建定时更新索引服务,甚至无法使用shell脚本(#!/bin/bash提示:can not found command),直接使用php ./occ fulltextsearch:live -q命令保持索引更新即可(执行命令后不要使用exit退出docker,直接关闭putty或SecureCRT窗口)