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 libSM.x86_64
[root@None ~]# cp libstdc++.so.6.0.26 /usr/lib64/
[root@None ~]# 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的解决方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值