Install WKHTMLTOX (WKHTMLTOPDF + WKHTMLTOIMAGE) on AWS ElasticBeanstalk
Asked Answered
E

7

13

I need WKHTMLTOX to be installed with my AWS EB app. I found this tutorial and it works except it supports old version.

Did anyone install the latest (0.12.3) version on AWS EB as this is a bit different folders structure?

Eldaelden answered 18/5, 2016 at 7:44 Comment(0)
E
17

After trying different tutorials, including this I finally got this working - I updated porteaux's answer.

I added below code to my EB *.config file in commands section:

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. The above tutorial is for Ubuntu and AWS EB runs Amazon Linux so they use yum instead of apt-get
  2. I had to use J switch with tar command to deal with *.xz file
  3. Finally I had to copy both wkhtmltopdf and wkhtmltoimage files to bin folder.

Done! I hope this will help others.

UPDATE: as per dhollenbeck suggestion

 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

I've updated my script already and can confirm that this work. Thanks dhollenbeck

Eldaelden answered 18/5, 2016 at 8:21 Comment(1)
Shortened it to one command: curl -L downloads.wkhtmltopdf.org/0.12/0.12.4/… | tar -xvJf - wkhtmltox/bin/wkhtmltopdf -C /usr/local^CCuttle
B
6

None of the other answers appear to be fully function at the moment (some because the links are no longer valid and some because of new dependency issues). I don't have enough reputation to comment on Lucas D'Avila's answer so here is the solution that is working for me today with Amazon-Linux/2.9.7:

Create an .ebextensions file named something like .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
Borsch answered 3/7, 2020 at 16:13 Comment(3)
This gives an error if the package is already installed. It is a good solution but lacks that detail.Shammer
Good point. I have edited the answer, reverting to an earlier version that I’ve used for a long time without problems.Borsch
It gives me the below error - any solution? [ERROR] update processes [web cfn-hup nginx healthd] pid symlinks failed with error Read pid source file /var/pids/web.pid failed with error:open /var/pids/web.pid: no such file or directory 2021/09/16 15:06:59.391295 [ERROR] An error occurred during execution of command [app-deploy] - [Track pids in healthd]. Stop running the command. Error: update processes [web cfn-hup nginx healthd] pid symlinks failed with error Read pid source file /var/pids/web.pid failed with error:open /var/pids/web.pid: no such file or directoryIroning
S
5

I have insufficient reputation to comment everywhere, so my apologies that this is another answer, rather than just a comment on @dhollenbeck answer. Happy to delete this if that is updated.

gna.org has shut down thus 04_command will fail. A working list of downloads is on wkhtmltopdf.org.

The updated YAML scripts would therefore be.

Create yaml file .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

and if you only want to install wkhtmltopdf once to speed up subsequent deployments:

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
Selfaddressed answered 30/5, 2017 at 11:36 Comment(0)
M
4

An updated answer for wkhtmltopdf 0.12.4 installed on 64bit Amazon Linux 2016.09 v3.3.0.

Create yaml file .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

If you only want to install wkhtmltopdf once to speed up subsequent deployments:

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

Metaphysic answered 17/1, 2017 at 0:42 Comment(0)
S
1

Complementing Elric Pedder anwser.

If wkhtmltopdf is already installed, it will give and error because yum will give a "Error: Nothing to do" and exit with -1 state. This will occur when you re deploy your elastic beanstalk.

In order to install wkhtmltopdf without failing, i check if is already installed.

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
Shammer answered 4/10, 2020 at 10:33 Comment(0)
R
0

You can also install wkhtmltopdf by creating a file like .ebextensions/packages.config with this content:

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
Ropable answered 31/10, 2019 at 2:30 Comment(0)
K
-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
Keepsake answered 31/7, 2018 at 3:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.