Centos7下的LibreOffice的搭建及自动化脚本部署
生活随笔
收集整理的這篇文章主要介紹了
Centos7下的LibreOffice的搭建及自动化脚本部署
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Centos7下的LibreOffice的搭建及自動化腳本部署
LibreOffice 簡介
LibreOffice 是一個強大的辦公套件 – 它清晰的界面和強大的工具讓您釋放您的創造力并增長您的生產力。
自由免費、全能、跨平臺的辦公套件
LibreOffice 是一款開放源代碼的自由免費全能辦公軟件,可運行于 Microsoft Windows, GNU/Linux 以及 macOS 等操作系統上。它包含了 Writer, Calc, Impress, Draw, Math 以及 Base 等組件,可分別用于文本文檔、電子表格、幻燈片演示文稿、繪圖文檔、數學公式編輯、數據庫管理等工作。
LibreOffice 采用對企業和個人用戶均免費的 GPL 2.0 授權協議。您可以自由分發該軟件,無需支付授權費用(但您仍然可以付費獲得經認證的專業支持)。它的源代碼完全公開,任何人都可以參與軟件的開發和維護。
支持各種文檔格式
LibreOffice 支持各種文檔格式。除了它原生支持的開放文檔格式 (OpenDocument Format, ODF) 外,它還支持許多的非開放格式,比如微軟的 Microsoft? Word, Excel, PowerPoint 以及 Publisher 的格式等。
可擴展性
LibreOffice 支持擴展功能。您可以使用 LibreOffice Basic, Python, C/C++, Java 等多個編程語言為 LibreOffice 開發擴展程序,以豐富其功能。LibreOffice的擴展軟件庫中已經有多個擴展可用。
另外,它還支持模板功能,您可以使用 LibreOffice 模板庫中已有的模板,或者創建自己的模板。
基于強大的基因
LibreOffice 的前身是 OpenOffice.org, 而 OpenOffice.org 最早是基于 StarOffice。它經過了許多年的開發和積累,并已被全球范圍內的眾多用戶使用。今天,LibreOffice 是目前最活躍的 OpenOffice.org 代碼庫后繼者,每 6 個月發布一個主要的新版本。
官網:https://zh-cn.libreoffice.org/
LibreOffice 能夠與 Microsoft Office 系列以及其它開源辦公軟件深度兼容,且支持的文檔格式相當全面
1、文本文檔:.odm, .sgl, .odt,.ott, .sxw, .stw, .fodt, .xml, .docx,.docm, .dotx, .dotm, .doc, .dot, .wps, .pdb, .hwp, .html, .htm, .lwp, .psw, .rft, .sdw, .vor, .txt, .wpd ,*.oth.
2、電子表格:.ods, .ots, .sxc, .stc, .fods, .xml, .xlsx, .xlsm, .xltm, .xltx, .xlsb, .xls, .xlc, .xlm, .xlw, .xlk, .sdc, .vor, .dif,.wk1, .wks, .123, .pxl, .wb2, *.csv.
3、演示文稿:.odp, .otp, .sti, .sxd, .fodp, .xml, .pptx, .pptm, .ppsx, .potm, .potx, .ppt, .pps, .pot, .sdd, .vor, *.sdp.
4、繪圖:.odg, .otg, .sxd, .std, .sgv,.sda, .vor, .sdd, .cdr, .svg, .vsd, .vst
5、網頁:.html, .htm, *.stw
6、主控文檔:*.sxg
7、公式:.odf, .sxm, .smf, .mml
8、數據庫文檔:*. odb
總的來說,LibreOffice的界面沒有微軟Office那么華麗,但非常簡單實用。它的六大組件對應Office絲毫不差,而且對系統配置要求較低,占用資源很少。
搭建過程
一、安裝Libreoffice;
下載3個rpm文件
[root@Libreoffice ~]# wget http://mirrors.ustc.edu.cn/tdf/libreoffice/stable/6.2.4/rpm/x86_64/LibreOffice_6.2.4_Linux_x86-64_rpm.tar.gz [root@Libreoffice ~]# wget http://mirrors.ustc.edu.cn/tdf/libreoffice/stable/6.2.4/rpm/x86_64/LibreOffice_6.2.4_Linux_x86-64_rpm_langpack_zh-CN.tar.gz [root@Libreoffice ~]# wget http://mirrors.ustc.edu.cn/tdf/libreoffice/stable/6.2.4/rpm/x86_64/LibreOffice_6.2.4_Linux_x86-64_rpm_sdk.tar.gz [root@Libreoffice ~]# ls LibreOffice_6.2.4_Linux_x86-64_rpm_langpack_zh-CN.tar.gz LibreOffice_6.2.4_Linux_x86-64_rpm_sdk.tar.gz LibreOffice_6.2.4_Linux_x86-64_rpm.tar.gz ##當本版本資源不可用時 訪問http://mirrors.ustc.edu.cn/tdf/libreoffice/stable尋找新版本;解壓rpm文件;
[root@Libreoffice ~]# mkdir /usr/libreoffice [root@Libreoffice ~]# tar zxf LibreOffice_6.2.4_Linux_x86-64_rpm.tar.gz -C /usr/libreoffice/ [root@Libreoffice ~]# tar zxf LibreOffice_6.2.4_Linux_x86-64_rpm_sdk.tar.gz -C /usr/libreoffice/ [root@Libreoffice ~]# tar zxf LibreOffice_6.2.4_Linux_x86-64_rpm_langpack_zh-CN.tar.gz -C /usr/libreoffice/ [root@Libreoffice ~]# ls /usr/libreoffice/ LibreOffice_6.2.4.2_Linux_x86-64_rpm LibreOffice_6.2.4.2_Linux_x86-64_rpm_sdk LibreOffice_6.2.4.2_Linux_x86-64_rpm_langpack_zh-CN進入到的RPMS目錄
上面三個文件解壓之后 每個里面都會有一個RPMS的文件夾,分別進入每個文件夾
[root@Libreoffice ~]# cd /usr/libreoffice/ [root@Libreoffice libreoffice]# cd LibreOffice_6.2.4.2_Linux_x86-64_rpm/RPMS/ [root@Libreoffice RPMS]#yum localinstall *.rpm [root@Libreoffice libreoffice]# cd .. [root@Libreoffice libreoffice]# cd LibreOffice_6.2.4.2_Linux_x86-64_rpm_langpack_zh-CN/RPMS/ [root@Libreoffice RPMS]#yum localinstall *.rpm [root@Libreoffice libreoffice]# cd .. [root@Libreoffice libreoffice]# cd LibreOffice_6.2.4.2_Linux_x86-64_rpm_sdk/ ##漢化包 [root@Libreoffice RPMS]#yum localinstall *.rpm [root@Libreoffice libreoffice]# cd ##用yum來進行rpm的安裝,不要用rpm命令來進行安裝 ##【注意:因為有依賴關系 libgnomevfs-2.so.0()(64bit),它被軟件包 libobasis5.0-gnome-integration-5.0.4.2-2.x86_64 需要所以不要使用rpm命令來進行安裝,rpm -ivh *.rpm 命令無法解決上面的依賴系。使用yum遇到上面的依賴關系的時候可以從網絡下載相應的包來解決依賴關系?!?到此為止libreoffice成功安裝了,但是命令還不可以用,所以我們需要修改一下環境變量;
[root@Libreoffice ~]# vim /etc/profile ##在最后添加兩行; export LibreOffice_PATH=/opt/libreoffice6.2/program export PATH=$LibreOffice_PATH:$PATH :wq 保存并退出 [root@Libreoffice ~]# source /etc/profile ##重讀環境變量 #這時命令就可以用了,命令格式如下 [root@Libreoffice ~]# soffice --headless --convert-to 目標格式(如pdf) 被轉換位置(如/tmp/test.doc) --outdir 轉換之后文件生成位置 #例: [root@Libreoffice ~]# soffice --headless --convert-to pdf /root/test1.docx --outdir /opt/abc/ #當報錯java的時候,需要安裝java環境;解決方法: [root@Libreoffice ~]# yum -y install java #安裝完成之后命令就可以使用了二、解決轉換pdf之后文檔字體亂碼問題;
先創建一個中文字體文件夾
[root@Libreoffice ~]# yum groupinstall "fonts" ##安裝字體識別目錄 [root@Libreoffice ~]# cd /usr/share/fonts/ ##存放字體路徑 [root@Libreoffice ~] #mkdir chinese/ ##創建中文目錄 [root@Libreoffice ~]# cd chinese/字體在主機電腦中就有,所以去C:\Windows\Fonts文件夾中去復制字體
將字體放到linux中,位置就是/chinese下;
然后給字體目錄及所有字體可讀權限;
[root@Libreoffice ~]# chmod -R 755 /usr/share/fonts/chinese/修改字體的識別的配置文件;
[root@Libreoffice ~]# vi /etc/fonts/fonts.conf #找到 Font directory list 字體列表,將目錄改成/chinese下 <dir>/usr/share/fonts/chinese</dir> ##更改后 :wq 保存并推出 [root@Libreoffice ~]# fc-cache [root@Libreoffice ~]# fc-list接下來就可以使用命令來進行轉換
如果想部署一個自動化轉換的腳本該怎么做呢?由于有專門的服務器配合NFS掛載做轉換,腳本狀態一直開啟,在這里我們寫的while死循環;
-
環境:Centos7.6
-
被掛載目錄 /opt/docx
-
開發人員將.docx文件上傳到其目錄下 通過NFS掛在共享到/opt/docx下
-
將轉換成pdf的文件與轉換完成的docx文件移動到/opt/文件夾中 文件夾名字為當天日期
腳本如下
[root@ceshi2 ~]# vi libreoffice.sh #/bin/bash ##解釋器 #author ouliwei ##作者 #date 2019.6.10 ##完成時間 while true ##while死循環 do for i in /opt/docx/*.docx ;do if [[ -f $i ]];then ##if判斷是否有docx文件if [[ -d /opt/$(date +%F) ]];then ##if判斷是否有時間目錄soffice --headless --convert-to pdf $i --outdir /opt/$(date +%F)mv $i /opt/$(date +%F)elsemkdir /opt/$(date +%F) ##如果沒有先創建soffice --headless --convert-to pdf $i --outdir /opt/$(date +%F)mv $i /opt/$(date +%F) ##移動已經轉換完成的文件fi elsesleep 60 ##如果沒有docx文件 則休眠一分鐘(一分鐘后再次從第一步開始) fi done done [root@ceshi2 ~]# chmod +x libreoffice.sh ##加執行權限 [root@ceshi2 ~]# ./libreoffice.sh ##執行腳本總結
以上是生活随笔為你收集整理的Centos7下的LibreOffice的搭建及自动化脚本部署的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一文了解人工智能神经网络的原理
- 下一篇: DeepFM算法