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



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

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

在尝试了包括本教程在内的不同教程后,我终于成功了——我更新了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. 我不得不使用带有tar命令的J开关来处理*.xz文件
  3. 最后,我不得不将wkhtmltopdf和wkhtmltoimage文件都复制到bin文件夹中

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

更新:根据dholenbeck建议

 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

我已经更新了我的脚本,可以确认这项工作。感谢dholenbeck

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

创建一个名为.ebextensions/wkhtmltopdf.config 的.eextensions文件

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

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

gna.org已经关闭,因此04_command将失败。下载的工作列表在wkhtmltopdf.org上。

因此,更新后的YAML脚本将为.

创建yaml文件.eextensions/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

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

创建yaml文件.eextensions/wkhtmltopdf.config

命令:03_命令:命令:yum-install--assumeyes zlib fontconfig freetype X1104_命令:命令:wgethttp://download.gna.org/wkhtmltopdf/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz05_命令:命令:tar-xJf wkhtmltox-0.124_linux-generic-amd64.tar.xz06_命令:命令:cp wkhtmltox/bin/wkhtmltopdf/usr/local/bin/wkhtmltopdf07_命令:命令:cp wkhtmltox/bin/wkhtmltoimage/usr/local/bin/wkhtmltoimage

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

命令:03_命令:命令:yum-install--assumeyes zlib fontconfig freetype X11测试:测试-f.wkhtmltopdf04_命令:命令:wgethttp://download.gna.org/wkhtmltopdf/0.12/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz测试:测试-f.wkhtmltopdf05_命令:命令:tar-xJf wkhtmltox-0.124_linux-generic-amd64.tar.xz测试:测试-f.wkhtmltopdf06_命令:命令:cp wkhtmltox/bin/wkhtmltopdf/usr/local/bin/wkhtmltopdf测试:测试-f.wkhtmltopdf07_命令:命令:cp wkhtmltox/bin/wkhtmltoimage/usr/local/bin/wkhtmltoimage测试:测试-f.wkhtmltopdf08_命令:命令:touch.wkhtmltopdf

补充Elric Pedder anwser。

如果已经安装了wkhtmltopdf,它将给出并出错,因为百胜将给出一个"错误:无所事事;并以-1状态退出。当你重新部署你的弹性豆茎时,就会发生这种情况。

为了安装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

您也可以通过创建一个类似.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
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

最新更新