【问题标题】:Install WKHTMLTOX (WKHTMLTOPDF + WKHTMLTOIMAGE) on AWS ElasticBeanstalk在 AWS ElasticBeanstalk 上安装 WKHTMLTOX (WKHTMLTOPDF + WKHTMLTOIMAGE)
【发布时间】:2016-09-14 13:31:46
【问题描述】:

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

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

【问题讨论】:

    标签: wkhtmltopdf amazon-elastic-beanstalk wkhtmltoimage


    【解决方案1】:

    在尝试了不同的教程(包括 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 文件夹中。

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

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

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

    【讨论】:

    【解决方案2】:

    我没有足够的声誉在任何地方发表评论,所以我很抱歉这是另一个答案,而不仅仅是对@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】:

      安装在 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

      【讨论】:

        【解决方案4】:

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

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

        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
        

        【讨论】:

        • 如果软件包已安装,则会出现错误。这是一个很好的解决方案,但缺少细节。
        • 好点。我已经编辑了答案,恢复到我使用了很长时间没有问题的早期版本。
        • 它给了我以下错误 - 任何解决方案? [错误] 更新进程 [web cfn-hup nginx healthd] pid 符号链接失败并出现错误读取 pid 源文件 /var/pids/web.pid 失败并出现错误:打开 /var/pids/web.pid:没有这样的文件或目录 2021 /09/16 15:06:59.391295 [错误] 执行命令 [app-deploy] - [Track pids in healthd] 期间发生错误。停止运行命令。错误:更新进程 [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跨度>
        【解决方案5】:

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

        【讨论】:

          【解决方案6】:

          补充 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
          

          【讨论】:

            【解决方案7】:
            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
            

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2018-04-14
              • 2016-01-01
              • 2020-11-01
              • 2016-06-07
              • 1970-01-01
              • 1970-01-01
              • 2014-07-05
              • 2014-11-21
              相关资源
              最近更新 更多