2016-05-18 80 views

回答

12

尝试不同的教程后,包括this我终于得到了这个工作 - 我更新了porteaux的答案。

我添加下面的代码到我的EB * config文件中的命令部分:

commands: 
    # install WKHTML 
    03_command: 
    command: yum install xz urw-fonts libXext openssl-devel libXrender 
    04_command: 
    command: wget http://download.gna.org/wkhtmltopdf/0.12/0.12.3/wkhtmltox-0.12.3_linux-generic-amd64.tar.xz 
    05_command: 
    command: tar -xJf wkhtmltox-0.12.3_linux-generic-amd64.tar.xz 
    06_command: 
    command: cp wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf 
    07_command: 
    command: cp wkhtmltox/bin/wkhtmltoimage /usr/local/bin/wkhtmltoimage 
  1. 上面的教程是Ubuntu和AWS EB运行Linux的亚马逊让他们用yum代替apt-get的
  2. 我不得不使用J开关与tar命令来处理* .xz文件
  3. 最后,我不得不复制wkhtmltopdf和wkhtmltoimage文件到bin文件夹。

完成!我希望这会帮助其他人。

UPDATE:按dhollenbeck建议

04_command: 
     command: wget https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz 
     test: test ! -f .wkhtmltopdf 
05_command: 
     command: tar -xJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz 
     test: test ! -f .wkhtmltopdf 
06_command: 
     command: cp wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf 
     test: test ! -f .wkhtmltopdf 
07_command: 
     command: cp wkhtmltox/bin/wkhtmltoimage /usr/local/bin/wkhtmltoimage 
     test: test ! -f .wkhtmltopdf 
08_command: 
     command: touch .wkhtmltopdf 

我已经更新了我的脚本,可以证实,这项工作。 谢谢dhollenbeck

3

已更新的答案wkhtmltopdf 0.12.4安装在64位Amazon Linux 2016.09 v3.3.0上。

创建YAML文件.ebextensions/wkhtmltopdf.config

 
commands: 
    03_command: 
    command: yum install --assumeyes zlib fontconfig freetype X11 
    04_command: 
    command: wget http://download.gna.org/wkhtmltopdf/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz 
    05_command: 
    command: tar -xJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz 
    06_command: 
    command: cp wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf 
    07_command: 
    command: cp wkhtmltox/bin/wkhtmltoimage /usr/local/bin/wkhtmltoimage 

如果你只是想安装wkhtmltopdf一次以加快后续部署:

 
commands: 
    03_command: 
    command: yum install --assumeyes zlib fontconfig freetype X11 
    test: test ! -f .wkhtmltopdf 
    04_command: 
    command: wget http://download.gna.org/wkhtmltopdf/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz 
    test: test ! -f .wkhtmltopdf 
    05_command: 
    command: tar -xJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz 
    test: test ! -f .wkhtmltopdf 
    06_command: 
    command: cp wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf 
    test: test ! -f .wkhtmltopdf 
    07_command: 
    command: cp wkhtmltox/bin/wkhtmltoimage /usr/local/bin/wkhtmltoimage 
    test: test ! -f .wkhtmltopdf 
    08_command: 
    command: touch .wkhtmltopdf 

3

我有足够的信誉评论随处可见,所以我很抱歉,这是另一个答案,而不仅仅是对@dhollenbeck答案的评论。很高兴删除这个如果更新。

gna.org已关闭,因此04_command将失败。 A working list of downloads在wkhtmltopdf.org上。

因此更新后的YAML脚本将会是。

创建YAML文件.ebextensions/wkhtmltopdf.config:

commands: 
    03_command: 
    command: yum install --assumeyes zlib fontconfig freetype X11 
    04_command: 
    command: wget https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz 
    05_command: 
    command: tar -xJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz 
    06_command: 
    command: cp wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf 
    07_command: 
    command: cp wkhtmltox/bin/wkhtmltoimage /usr/local/bin/wkhtmltoimage 

,如果你只是想安装一次wkhtmltopdf加快后续部署:

commands: 
    03_command: 
    command: yum install --assumeyes zlib fontconfig freetype X11 
    test: test ! -f .wkhtmltopdf 
    04_command: 
    command: wget https://downloads.wkhtmltopdf.org/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz 
    test: test ! -f .wkhtmltopdf 
    05_command: 
    command: tar -xJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz 
    test: test ! -f .wkhtmltopdf 
    06_command: 
    command: cp wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf 
    test: test ! -f .wkhtmltopdf 
    07_command: 
    command: cp wkhtmltox/bin/wkhtmltoimage /usr/local/bin/wkhtmltoimage 
    test: test ! -f .wkhtmltopdf 
    08_command: 
    command: touch .wkhtmltopdf