12

我需要将 WKHTMLTOX 与我的 AWS EB 应用程序一起安装。我找到了这个教程,它可以工作,除了它支持旧版本。

是否有人在 AWS EB 上安装了最新(0.12.3)版本,因为这是一个有点不同的文件夹结构?

4

7 回答 7

16

在尝试了不同的教程(包括这个)之后,我终于得到了这个工作 - 我更新了 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 运行 Amazon Linux,因此他们使用 yum 而不是 apt-get
  2. 我不得不使用 J 开关和 tar 命令来处理 *.xz 文件
  3. 最后我不得不将 wkhtmltopdf 和 wkhtmltoimage 文件都复制到 bin 文件夹中。

完毕!我希望这对其他人有帮助。

更新:根据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

我已经更新了我的脚本并且可以确认这个工作。谢谢多伦贝克

于 2016-05-18T08:21:09.623 回答
5

我没有足够的声誉在任何地方发表评论,所以我很抱歉这是另一个答案,而不仅仅是对@dhollenbeck 答案的评论。如果更新了,很高兴删除它。

gna.org 已关闭,因此 04_command 将失败。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
于 2017-05-30T11:36:58.833 回答
5

目前,其他答案似乎都没有完全发挥作用(有些是因为链接不再有效,有些是因为新的依赖问题)。我没有足够的声誉来评论 Lucas D'Avila 的回答,所以这里是今天使用 Amazon-Linux/2.9.7 为我工作的解决方案:

创建一个 .ebextensions 文件,命名为.ebextensions/wkhtmltopdf.config

container_commands:
    1_install_wkhtmltopdf:
        command: yum -y install fontconfig libXrender libXext xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi freetype libpng zlib libjpeg-turbo openssl icu
        ignoreErrors: true

    2_install_wkhtmltopdf:
        # see: https://wkhtmltopdf.org/downloads.html for updates
        command: wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz --dns-timeout=5 --connect-timeout=5 --no-check-certificate
        test: test ! -f .wkhtmltopdf

    3_install_wkhtmltopdf:
        command: tar -xJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
        test: test ! -f .wkhtmltopdf

    4_install_wkhtmltopdf:
        command: cp wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
        test: test ! -f .wkhtmltopdf

    5_install_wkhtmltopdf:
        command: cp wkhtmltox/bin/wkhtmltoimage /usr/local/bin/wkhtmltoimage
        test: test ! -f .wkhtmltopdf

    6_install_wkhtmltopdf:
        command: touch .wkhtmltopdf
于 2020-07-03T16:13:58.953 回答
4

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

创建 yaml 文件 .ebextensions/wkhtmltopdf.config

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

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

命令:
  03_命令:
    命令:yum install --assumeyes zlib fontconfig freetype X11
    测试一下 !-f .wkhtmltopdf
  04_命令:
    命令:wget http://download.gna.org/wkhtmltopdf/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
    测试一下 !-f .wkhtmltopdf
  05_命令:
    命令:tar -xJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
    测试一下 !-f .wkhtmltopdf
  06_命令:
    命令:cp wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf
    测试一下 !-f .wkhtmltopdf
  07_命令:
    命令:cp wkhtmltox/bin/wkhtmltoimage /usr/local/bin/wkhtmltoimage
    测试一下 !-f .wkhtmltopdf
  08_命令:
    命令:触摸 .wkhtmltopdf

于 2017-01-17T00:42:04.230 回答
1

补充 Elric Pedder anwser。

如果已经安装了 wkhtmltopdf,它会给出错误,因为 yum 会给出“错误:无事可做”并以 -1 状态退出。这将在您重新部署弹性 beantalk 时发生。

为了安装 wkhtmltopdf 而不会失败,我检查是否已经安装。

wkhtmltopdf.config

container_commands:
    01_install_wkhtmltopdf:
        command: sudo yum -q list installed wkhtmltox.x86_64 &>/dev/null && sudo yum -y reinstall https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.amazonlinux2.x86_64.rpm || sudo yum -y install https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.amazonlinux2.x86_64.rpm
于 2020-10-04T10:33:13.340 回答
0

您还可以通过创建类似.ebextensions/packages.config以下内容的文件来安装 wkhtmltopdf:

packages:
  rpm:
    # find more versions on https://wkhtmltopdf.org/downloads.html
    wkhtmltopdf: https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.centos7.x86_64.rpm
于 2019-10-31T02:30:34.073 回答
-1
wget https://downloads.wkhtmltopdf.org/0.12/0.12.5/wkhtmltox-0.12.5-1.centos6.x86_64.rpm

sudo yum install wkhtmltox-0.12.5-1.centos6.x86_64.rpm
于 2018-07-31T03:20:13.620 回答