LibreOffice安装

CentOS7
[root@None ~]# yum -y install libreoffice
[root@None ~]# yum -y install libreoffice-writer
[root@None ~]# yum -y install ibus
[root@None ~]# yum -y install cairo cups-libs libSM
[root@None ~]# yum -y install libreoffice-headless
[root@None ~]# mkdir /usr/share/fonts/chinese
把Windows系统的字体(C:\Windows\Fonts)打包复制到chinese目录下
chmod -R 755 /usr/share/fonts/chinese #修改权限
[root@None ~]# fc-cache -fv #建立字体缓存
[root@None ~]# fc-list | grep chinese #可以查看到已安装新增的字体了

CentOS6.10
[root@None ~]# yum -y install libreoffice
[root@None ~]# yum -y install libreoffice-langpack-zh-Han* #安装中文包
[root@None ~]# libreoffice --headless --convert-to pdf /root/libreoffice.html /tmp/
[root@None ~]# libreoffice --headless --convert-to pdf /root/2021.docx --outdir /tmp/
/usr/lib64/libreoffice/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)
[root@None ~]# yum -y install libreoffice-headless #报以上错误安装此包

CentOS6.10 libreoffce7.0.6安装
[root@None ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://file.kangle.odata.cc/repo/Centos-6.repo
[root@None ~]# wget -O /etc/yum.repos.d/epel.repo http://file.kangle.odata.cc/repo/epel-6.repo
[root@None ~]# yum makecache
[root@None ~]# yum install /opt/LibreOffice_7.0.6.2_Linux_x86-64_rpm/RPMS/*.rpm
[root@None ~]# yum install /opt/LibreOffice_7.0.6.2_Linux_x86-64_rpm_langpack_zh-CN/RPMS/*.rpm
[root@None ~]# yum -y install cairo cups-libs
[root@None ~]# cp libstdc++.so.6.0.26 /usr/lib64/
[root@None lib64]# cd /usr/lib64
[root@None lib64]# mv libstdc++.so.6 libstdc++.so.6.bak
[root@None lib64]# ln -s libstdc++.so.6.0.26 libstdc++.so.6
[root@None opt]# mkdir glibc-2.15
[root@None opt]# cd glibc-2.15
[root@None glibc-2.15]# tar xf glibc-2.15.tar.gz
[root@None glibc-2.15]# tar glibc-ports-2.15.tar.xz
[root@None glibc-2.15]# tar xf glibc-ports-2.15.tar.xz
[root@None glibc-2.15]# mv glibc-ports-2.15 glibc-2.15/ports
[root@None glibc-2.15]# ./glibc-2.15/configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
[root@None glibc-2.15]# make && make install
[root@None ~]# wget http://zlib.net/zlib-1.2.11.tar.gz
[root@None ~]# tar zxf zlib-1.2.11.tar.gz
[root@None ~]# cd zlib-1.2.11
[root@None zlib-1.2.11]# ./configure
[root@None zlib-1.2.11]# make && make install
[root@None ~]# cp /lib64/libz.so.1 libz.so.1_copy
[root@None ~]# rm -fr /lib64/libz.so.1
[root@None ~]# ln -s /usr/local/lib/libz.so.1.2.11 /lib64/libz.so.1
[root@None ~]# cd /lib64
[root@None lib64]# cp /usr/local/lib/libz.so.1.2.11 ./
[root@None lib64]# ln -s libz.so.1.2.11 libz.so.1
[root@None ~]# mkdir /opt/glibc-2.17
[root@None ~]# cd /opt/glibc-2.17/
[root@None glibc-2.17]# tar xf glibc-2.17.tar.gz
[root@None glibc-2.17]# ./glibc-2.17/configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
[root@None glibc-2.17]# make && make install
[root@None ~]# mkdir /usr/share/fonts/chinese
[root@None ~]# cd /usr/share/fonts/chinese
[root@None chinese]# rename .ttc .ttf *.ttc #批量修改.ttc后缀为.ttf
[root@None chinese]# chmod -R 755 /usr/share/fonts/chinese
[root@None chinese]# yum -y install fontconfig
[root@None chinese]# yum -y install mkfontscale
[root@None chinese]# mkfontscale
[root@None chinese]# mkfontdir
[root@None chinese]# fc-cache -fv
[root@None chinese]# fc-list :lang=zh #查看安装的字体
#php调libreoffice命令格式(sudo /usr/bin/libreoffice7.0 --headless --convert-to pdf /file/test.docx --outdir /tmp >/dev/null 2>&1 &)
[root@None ~]# vim /etc/sudoers #添加sudo授权,不需要输root密码
%nobody ALL=(root) NOPASSWD: /usr/bin/libreoffice7.0
[root@None ~]# ldd /opt/libreoffice7.0/program/soffice.bin
[root@None ~]# libreoffice7.0 --headless --convert-to pdf 053dce97c4903ad892b34454d19825d2.docx --outdir /tmp/

参考链接
      https://blog.csdn.net/guo_qiangqiang/article/details/107161705 #centos610解决linux安装中文字体的方法
      https://blog.csdn.net/ljihe/article/details/77250206 #centos610上使用libreoffice命令行方式将word、excel、ppt转成pdf
      https://www.cnblogs.com/oumi/p/11296768.html #centos610安装libreoffice缺失字体
      https://www.cnblogs.com/oumi/p/11290197.html #安装libreoffice
      https://www.cnblogs.com/chai-/p/10731076.html
      https://blog.csdn.net/mxiawang/article/details/103256267/
      https://blog.csdn.net/zhoubl668/article/details/80285317
      https://blog.csdn.net/a13568hki/article/details/108667044
      https://v3u.cn/a_id_96 #centos7
      http://ftp.gnu.org/gnu/glibc/
      https://zhuanlan.zhihu.com/p/141341452 #/lib/libapr-1.so.0: undefined symbol: dlopen的解决方法

上一篇:开源小捷,阿尔巴尼亚首都*办公采用 LibreOffice


下一篇:linux下doc转docx