無法使用 xvfb 在遠端 VPS 伺服器上執行 X 伺服器

無法使用 xvfb 在遠端 VPS 伺服器上執行 X 伺服器

我的應用程式使用該庫https://github.com/wkhtmltopdf/wkhtmltopdf這需要 X 伺服器。這是一個解決方法:

echo -e '#!/bin/bash\nxvfb-run -a --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf -q $*' > /usr/bin/wkhtmltopdf.sh
chmod a+x /usr/bin/wkhtmltopdf.sh
ln -s /usr/bin/wkhtmltopdf.sh /usr/local/bin/wkhtmltopdf
wkhtmltopdf http://www.google.com output.pdf

我已經透過 pacman 安裝了 xvfb 並按照連結中的步驟進行操作。然而,什麼都沒有改變:它仍然回傳一個錯誤

  wkhtmltopdf http://www.google.com output.pdf

===>

 "qt.qpa.screen: QXcbConnection: Could not connect to display :0.0"

$ which wkhtmltopdf
/usr/local/bin/wkhtmltopdf

答案1

您應該嘗試運行 wkhtmltopdf.sh 而不僅僅是 wkhtmltopdf。似乎您正在調用原始二進位而不是您創建的 xvfb 包裝器。

要確定您正在運行哪一個,請嘗試執行“which wkhtmltopdf”。

相關內容