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

时间:2016-05-18 07:44:01

标签: wkhtmltopdf amazon-elastic-beanstalk wkhtmltoimage

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

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

7 个答案:

答案 0 :(得分:14)

在尝试了不同的教程之后,包括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运行Amazon Linux,因此他们使用yum而不是apt-get
  2. 我不得不使用J开关和tar命令来处理* .xz文件
  3. 最后我不得不将wkhtmltopdf和wkhtmltoimage文件复制到bin文件夹。
  4. 完成!我希望这会有所帮助。

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

答案 1 :(得分:4)

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

创建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

答案 2 :(得分:4)

我的声誉不足以到处评论,所以我道歉这是另一个答案,而不仅仅是对@dhollenbeck答案的评论。如果有更新,请尽快删除。

gna.org已关闭,因此04_command将失败。 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

答案 3 :(得分: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

答案 4 :(得分:0)

目前,其他答案似乎均未完全起作用(某些原因是链接不再有效,而某些原因是新的依赖性问题)。我没有足够的声誉来评论卢卡斯·德阿维拉的答案,所以这是今天在Amazon-Linux / 2.9.7上对我有用的解决方案:

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

container_commands:
    01_install_wkhtmltopdf:
        command: sudo yum -y install https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.amazonlinux2.x86_64.rpm

答案 5 :(得分:0)

补充Elric Pedder答案。

如果已经安装了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

答案 6 :(得分:-2)

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
相关问题