LibOffice与CentOS集成步骤如下:
安装LibOffice
sudo yum update -y
sudo yum install libreoffice -y # 安装核心组件
sudo snap install libreoffice --classic
配置为默认办公软件
/etc/xdg/mimeapps.list,将文档/表格/演示文稿的默认应用设为libreoffice-*。集成到桌面环境
/usr/share/applications/libreoffice.desktop,内容如下:[Desktop Entry]
Version=1.0
Type=Application
Name=LibreOffice
Exec=libreoffice %f
Icon=libreoffice
Categories=Office;
sudo update-desktop-database。命令行工具集成
libreoffice命令直接操作文档,如:libreoffice --writer file.docx # 用Writer打开Word文档
libreoffice --calc file.xlsx # 用Calc打开Excel文档
高级集成(可选)
soffice --headless --accept="socket,host=0.0.0.0,port=8100;urp;" --nofirststartwizard &
libreoffice-python后编写脚本操作文档。注意:CentOS 7/8需确保系统已更新,部分旧版本可能需要手动解决依赖问题。建议优先使用CentOS 7+或迁移至受支持的发行版以获得长期支持。