在 CentOS 上“启动 LibreOffice”通常有两种场景:
下面分别说明。
rpm -qa | grep libreoffice
或
which libreoffice
如果没有安装:
sudo yum install libreoffice
sudo dnf install libreoffice
安装完整套件(推荐):
sudo dnf group install "LibreOffice"
如果你使用的是 GNOME / KDE:
libreoffice &
或在菜单中搜索 LibreOffice Writer / Calc / Impress。
libreoffice --headless
libreoffice --headless --convert-to pdf test.docx
libreoffice --headless --convert-to pdf --outdir /tmp test.docx
libreoffice --headless --accept="socket,host=127.0.0.1,port=8100;urp;"
说明你在使用 SSH 且无桌面环境
✅ 加 --headless 参数即可
安装中文字体:
sudo dnf install wqy-zenhei-fonts
LibreOffice 默认禁止 root 运行:
libreoffice --headless --nofirststartwizard
或使用普通用户运行。
如果你能告诉我:
我可以给你更精确的命令。