wkhtmltopdf error in apache log
问题 exec("wkhtmltopdf test.html output.pdf"); In the php command line it works but if I try to call it from apache it doesn't create the pdf file and the log show this: $ tail -f /var/log/apache2/error.log wkhtmltopdf: cannot connect to X server 回答1: You can use Xvfb to emulate a x-environment <?php exec("xvfb-run -a wkhtmltopdf test.html output.pdf"); OR <?php exec("startx -- `which Xvfb` :1 -screen 0 800x600x24 && DISPLAY=:1 && wkhtmltopdf test.html output.pdf"); I made this script for myself