使用docker安装onlyoffice Document Server
编辑历史:
2018.5.24 小赖 文档初始化
1. 系统要求
- 中央处理器 双核2 GHz或更好
- 内存 2 GB或更多
- 硬盘 至少40 GB的可用空间
- 其他要求 至少2 GB的交换
- OS 内核版本为3.10或更高版本的amd64 Linux发行版
- 其他要求 :Docker:版本1.10或更高版本
2. 安装文档服务器
NB: Docker默认指定Google DNS服务器。如果您的文档服务器无法访问
Internet,我们建议您将默认的Docker DNS地址更改为本地DNS服务器的地址。为此,请转到该/etc/default/docker文件,并将以下行中的IP地址更改为本地网络中DNS服务器的IP地址:
docker_OPTS="--dns 8.8.8.8"
安装Docker后,运行它并执行以下命令:
sudo docker run -i -t -d -p 80:80 --restart=always onlyoffice/documentserver
3. 安装文档服务器:将数据存储在容器外部(强烈建议)
所有数据都存储在以下位置的特定目录中:
/var/log/onlyoffice 用于文档服务器日志
/var/www/onlyoffice/Data 用于映射数据
/var/lib/onlyoffice 用于文件缓存
/var/lib/postgresql 用于映射数据库
要访问位于容器外部的数据,您需要安装卷。可以通过在docker run命令中指定-v选项来完成。
sudo docker run -i -t -d -p 80:80 --restart=always \
-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 onlyoffice/documentserver
通常,您不需要存储容器数据,因为容器操作不依赖于其状态。保存数据将很有用:
- 便于访问容器数据,如日志;
- 删除容器内数据大小的限制;
- 当使用在容器外部启动的服务时,例如PostgreSQL,Redis,RabbitMQ。
4. 安装文档服务器:将镜像做成服务器安装
情况1:容器中支持ipv6
启动服务命令:
/app/onlyoffice/run-document-server.sh
情况2:容器中不支持ipv6
- 修改容器中的镜像中的/etc/nginx/conf.d/onlyoffice-documentserver.conf中 listen [::]:80类似的,都会需要注释掉。
- 修改 /etc/hosts 文件,将下图中的标红的删除掉,因为涉及到ipv6
3.注释掉 /etc/nginx/sites-available/default 文件中如下图标红部分
15282746748138.jpg4.重启nginx
service nginx restart
- 将下面的命令拷贝到.sh文件中,然后运行这个脚本。
#!/bin/bash
apt-get update
apt-get install -y language-pack-zh-hans
export LANG=zh_CN.UTF-8
export LC_CTYPE=zh_CN.UTF-8
export KERL_BUILD_BACKEND=git
cd ~
cp /etc/apt/sources.list ~/sources.list
rm -f /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse" > /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse" >> /etc/apt/sources.list
echo "deb https://dl.bintray.com/rabbitmq/debian trusty main" | tee /etc/apt/sources.list.d/bintray.rabbitmq.list
wget -O- https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc | apt-key add -
wget -c -O- http://packages.erlang-solutions.com/ubuntu/erlang_solutions.asc | apt-key add -
echo "deb http://packages.erlang-solutions.com/ubuntu trusty contrib" | tee -a /etc/apt/sources.list.d/erlang_solutions.list
apt-get update
apt-get -y install build-essential autoconf libssl-dev libncurses5-dev
apt-get -y install erlang
apt-get remove rabbitmq-server
apt-get install rabbitmq-server
cd /app/onlyoffice
./run-document-server.sh
5. 检验服务安装成功与否
使用浏览器访问:
http://<host:port>/web-apps/apps/api/documents/api.js //port默认启动占用80
6. 解决中文乱码问题
docker exec -it xxx /bin/bash //xxx代表onlyoffice/documentserver docker的容器name或者id
cd /usr/share/fonts/
rm -rf .... //删除fonts文件夹中除了truetype的所有文件及文件夹
cd truetype
rm -rf .... //删除truetype文件夹中除了custom的所有文件及文件夹
wget https://github.com/neroxps/Docker-Only-Office-Chinese-font/raw/master/winfont/msyh.ttc
wget https://github.com/neroxps/Docker-Only-Office-Chinese-font/raw/master/winfont/msyhbd.ttc
wget https://github.com/neroxps/Docker-Only-Office-Chinese-font/raw/master/winfont/msyhl.ttc
wget https://github.com/neroxps/Docker-Only-Office-Chinese-font/raw/master/winfont/simfang.ttf
wget https://github.com/neroxps/Docker-Only-Office-Chinese-font/raw/master/winfont/simhei.ttf
wget https://github.com/neroxps/Docker-Only-Office-Chinese-font/raw/master/winfont/simkai.ttf
wget https://github.com/neroxps/Docker-Only-Office-Chinese-font/raw/master/winfont/simsun.ttc
wget https://github.com/neroxps/Docker-Only-Office-Chinese-font/raw/master/winfont/simsunb.ttf
最后运行 documentserver-generate-allfonts.sh脚本,清除浏览器缓存并重新打开页面。
网友评论