wicked_pdf 不在 Ubuntu 服务器上运行:wkhtmltopdf:无法连接到 X 服务器 [英] wicked_pdf does not run on Ubuntu server : wkhtmltopdf: cannot connect to X server
问题描述
我正在尝试在我的生产服务器上使用 wicked_pdf 但它一直失败:
I'm trying to use wicked_pdf on my prod server but it keeps failling :
RuntimeError (Failed to execute:
"/usr/bin/wkhtmltopdf" -q "file:////tmp/wicked_pdf20130709-23109-1adqx5g.html" "/tmp/wicked_pdf_generated_file20130709-23109-1ic5dbe.pdf"
Error: PDF could not be generated!
Command Error: wkhtmltopdf: cannot connect to X server
):
app/controllers/contrats_controller.rb:15:in `block (2 levels) in show'
app/controllers/contrats_controller.rb:11:in `show'
我试图遵循这个答案:wkhtmltopdf:无法连接到 X 服务器 但还是不行.
I tried to follow this answer : wkhtmltopdf: cannot connect to X server but it still does not work.
推荐答案
这篇文章帮助我解决了我的问题:http://www.stormconsultancy.co.uk/blog/development/generate-pdfs-in-rails-with-pdfkit-and-deploying-to-a-server/
This post helped me to resolve my problem : http://www.stormconsultancy.co.uk/blog/development/generating-pdfs-in-rails-with-pdfkit-and-deploying-to-a-server/
我在这里复制了这篇文章中帮助我安装它的步骤:
I'm reproducing here the step from this post that helped me to install it :
# first, installing dependencies
sudo aptitude install openssl build-essential xorg libssl-dev
# for 64bits OS
wget http://wkhtmltopdf.googlecode.com/files/wkhtmltopdf-0.9.9-static-amd64.tar.bz2
tar xvjf wkhtmltopdf-0.9.9-static-amd64.tar.bz2
mv wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf
chmod +x /usr/local/bin/wkhtmltopdf
他还创建了一个初始化程序来告诉 pdfKit 它在哪里,所以这个方法适用于邪恶的 PDF 和 PDF Kit.
He also create an initializer to tell to pdfKit where it is, so this method is for wicked PDF and PDF Kit.
这篇关于wicked_pdf 不在 Ubuntu 服务器上运行:wkhtmltopdf:无法连接到 X 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!