在AWS ElasticBeanstalk上安装WKHTMLTOX(WKHTMLTOPDF + WKHTMLTOIMAGE)

Str*_*bek 7 wkhtmltopdf wkhtmltoimage amazon-elastic-beanstalk

我需要使用我的AWS EB应用程序安装WKHTMLTOX.我找到了这个教程,除了支持旧版本外,它还可以工作.

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

Str*_*bek 15

尝试不同的教程,包括经过这个我终于得到这个工作-我更新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
Run Code Online (Sandbox Code Playgroud)
  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
Run Code Online (Sandbox Code Playgroud)

我已经更新了我的脚本,可以确认这项工作.谢谢dhollenbeck


Elr*_*der 6

目前,其他答案似乎都没有完全发挥作用(有些是因为链接不再有效,有些是因为新的依赖问题)。我没有足够的声誉来评论 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
Run Code Online (Sandbox Code Playgroud)

  • 好点子。我已经编辑了答案,恢复到我使用了很长时间而没有问题的早期版本。 (2认同)

Ali*_*r H 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
Run Code Online (Sandbox Code Playgroud)

如果您只想安装 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
Run Code Online (Sandbox Code Playgroud)