生产中wkhtmltopdf-binary gem的一个问题

时间:2017-10-17 14:53:31

标签: ruby-on-rails ruby nginx wkhtmltopdf wicked-pdf

我正在使用gem'wicked_pdf'将html转换为pdf。 它在开发模式下工作正常。但是在生产过程中它会被nginx抛出错误。这是生产中的错误日志:

I, [2017-10-17T12:34:09.726920 #17004]  INFO -- : [4a94b9f6-fdf6-4e55-b325-9b3096132d4e] Completed 500 Internal Server Error in 2638ms (ActiveRecord: 30.6ms)
F, [2017-10-17T12:34:09.729566 #17004] FATAL -- : [4a94b9f6-fdf6-4e55-b325-9b3096132d4e]   
F, [2017-10-17T12:34:09.729763 #17004] FATAL -- : [4a94b9f6-fdf6-4e55-b325-9b3096132d4e] RuntimeError (Failed to execute:
["/home/deploy/phoenix/shared/bundle/ruby/2.4.0/bin/wkhtmltopdf", "-q", "file:////tmp/wicked_pdf20171017-17004-ps7ahv.html", "/tmp/wicked_pdf_generated_file20171017-17004-17rkfch.pdf"]
Error: PDF could not be generated!
Command Error: /home/deploy/phoenix/shared/bundle/ruby/2.4.0/gems/wkhtmltopdf-binary-0.12.3.1/bin/wkhtmltopdf_linux_amd64: error while loading shared libraries: libXrender.so.1: cannot open shared object file: No such file or directory
):
F, [2017-10-17T12:34:09.729900 #17004] FATAL -- : [4a94b9f6-fdf6-4e55-b325-9b3096132d4e]   
F, [2017-10-17T12:34:09.730005 #17004] FATAL -- : [4a94b9f6-fdf6-4e55-b325-9b3096132d4e] app/controllers/orders_controller.rb:16:in `block (2 levels) in show'
[4a94b9f6-fdf6-4e55-b325-9b3096132d4e] app/controllers/orders_controller.rb:13:in `show'

我觉得我有一个缺少lib的问题:libXrender.so.1

我在生产ubuntu 16.04 ruby​​:2.4.1和rails 5.1.4上使用 我可以得到你的支持吗?

1 个答案:

答案 0 :(得分:2)

听起来您的生产服务器没有安装xserver。

sudo apt-get install libxrender1

应该在Ubuntu上为你工作。