软件包安装
1. 说明
本文档采用rpm包方式安装,操作系统为centos
2 下载openoffice rpm包
创建源码包存放目录
mkdir /usr/local/src/openoffice cd /usr/local/src/openoffice wget https://jaist.dl.sourceforge.net/project/openofficeorg.mirror/4.1.5/binaries/zh-CN/Apache_OpenOffice_4.1.5_Linux_x86-64_install-rpm_zh-CN.tar.gz
#如果网速很慢,换个网络环境下载
下载地址:http://www.openoffice.org/zh-cn/ (需要下载rpm格式的)
3 解压安装
tar -xvzf Apache_OpenOffice_4.1.5_Linux_x86-64_install-rpm_zh-CN.tar.gz
解压后会在当前目录里生成一个zh-CN目录, RPMS/ 里面都是rpm文件,我们需要安装这些文件
cd /usr/local/src/openoffice /zh-CN/RPMS/ rpm -ivh *.rpm
安装完后会在当前目录下生成一个desktop-integration目录
cd /usr/local/src/zh-CN/RPMS/desktop-integration/ rpm -ivh openoffice4.1.6-redhat-menus-4.1.5-9789.noarch.rpm
4 启动openoffice
临时启动
/opt/openoffice4/program/soffice -headless -accept=“socket,host=127.0.0.1,port=8100;urp;” -nofirststartwizard
后台永久运行
/opt/openoffice4/program/soffice -headless -accept=“socket,host=127.0.0.1,port=8100;urp;” -nofirststartwizard &
加入到开机自启动
vim /etc/rc.local nohup /opt/openoffice4/program/soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard &
删除openoffice
在program文件夹下执行:
rpm -erpm -qa |grep openofficerpm -qa |grep ooobasis
查看openoffice进程
netstat -lnp |grep 或者 ps -ef|grep soffice
问题
javaldx: Could not find a Java Runtime Environment!
yum install java-1.8.0-openjdk
Docker安装
使用打包好的openoffice4镜像
docker build --pull -t xiaojun207/openoffice4-daemon --build-arg OO_VERSION=4.1.7 .
运行
docker run -d -u 123456 --name soffice -p 8100:8100 -v /data/:/data/ xiaojun207/openoffice4-daemon:latest
参考:
https://hub.docker.com/r/xiaojun207/openoffice4-daemon
自己动手制作openoffice4镜像
制作openoffice镜像
资源准备,包括 OpenOffice 压缩包、Dockerfile 文件、sources.list 三个。
$ ls Apache_OpenOffice_4.1.7_Linux_x86-64_install-deb_zh-CN.tar Dockerfile sources.list
本地资源新建 Dockerfile 文件:
#基础镜像为debian FROM yongqiang/debian-jdk8 COPY sources.list /etc/apt/ RUN apt-get update && apt-get upgrade && apt-get install -y libxt6 libxext6 libfreetype6 libxrender1 COPY Apache_OpenOffice_4.1.7_Linux_x86-64_install-deb_zh-CN.tar / #解压 RUN tar -xvf Apache_OpenOffice* #删除压缩包 RUN rm -f Apache_OpenOffice_* #安装OpenOffice RUN dpkg -i zh-CN/DEBS/*.deb || true RUN dpkg -i zh-CN/DEBS/desktop-integration/*.deb || true #删除解压缩的文件 RUN rm -Rf zh-CN #暴露接口 EXPOSE 8100 #启动服务,占用8100端口 CMD /opt/openoffice4/program/soffice -headless -nofirststartwizard -accept="socket,host=0.0.0.0,port=8100;urp;"
构建镜像
$ docker build -t openoffice:v1 .
启动容器
$ docker run -d -it -p 8100:8100 openoffice:v1
提交到DockerHub
$ docker tag 6cefc75591a0 yongqiang/openoffice:v1 $ docker push yongqiang/openoffice:v1
问题解决
制作镜像问题
/opt/openoffice4/program/soffice.bin: error while loading shared libraries: libXext.so.6: cannot open shared object file: No such file or directory
解决方案:apt-get install libxext6
/opt/openoffice4/program/soffice.bin: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory
解决方案:apt-get install libfreetype6
javaldx: Could not find a Java Runtime Environment!
解决方案:FROM yongqiang/debian-jdk8
no suitable windowing system found, exiting.
解决方案:apt-get install libxt6 libxrender1
安装openoffice问题
问题一:
$ soffice X11 connection rejected because of wrong authentication. X11 connection rejected because of wrong authentication. /opt/openoffice4/program/soffice.bin X11 error: Can't open display: Set DISPLAY environment variable, use -display option or check permissions of your X-Server (See "man X" resp. "man xhost" for details)
解决:
$ vncserver $ export DISPLAY=localhost:1 $ xhost + access control disabled, clients can connect from any host
在Linux下设置xhost方法步骤
第一步:用root登陆linux,启动vnc服务;
第二步:根据vnc起来的端口,设置export DISPLAY=localhost:1(1表示vnc在第一个tty上启动的),vnc的启动信息见附件1;
第三步:执行xhost +,并且提示“access control disabled, clients can connect from any host”才正确。
问题二:
Fatal server error:
could not open default font ‘fixed’
解决方案:apt-get -y install xfonts-base
安装完后从新启动vnc服务即可。
问题三:
Xlib: extension “RANDR” missing on display “localhost:1”.
解决方案:apt-get -y install xfonts-base
集成SpringBoot应用
参考:
https://openoffice.apache.org/
https://hub.docker.com/r/evan11/openoffice4-java8
https://hub.docker.com/r/xiaojun207/openoffice4-daemon
https://blog.csdn.net/yongyundeshiguang/article/details/113646731