【问题标题】:AWS Elastic BeanStalk Phantom BugAWS Elastic BeanStalk 幻影错误
【发布时间】:2020-04-21 16:18:08
【问题描述】:

我在 AWS Elastic Beanstalk 中进行生产时遇到了一个错误,否则它在本地和 Heroku 中都运行良好。日志说:

html-pdf: Failed to load PhantomJS module. You have to set the path to the PhantomJS binary using 'options.phantomPath'

确实,我正在使用html-pdf,但由于某种原因,它在 AWS EB 上失败了。 EB 是:64 位 Amazon Linux/4.14.1 和 Node 10.17

【问题讨论】:

    标签: amazon-web-services phantomjs amazon-elastic-beanstalk html-pdf


    【解决方案1】:

    我只是设法找到解决我环境中类似问题的方法。运行节点 10.15。也许你已经解决了这个问题——如果是这样,恭喜!完全免责声明,我不是 Elasticbeanstalk 配置方面的专家,但想分享一个潜在的解决方案。

    尝试在/.ebextension中添加一个yaml配置文件,内容如下:

    commands:
        99-installphantom:
            env:
                PATH: /sbin:/bin:/usr/sbin:/usr/bin:/opt/aws/bin:/opt/elasticbeanstalk/node-install/node-v10.15.1-linux-x64/bin/
            command: npm install -g phantomjs-prebuilt --unsafe-perm
    

    这会强制全局安装 phantomjs,--unsafe-perm 标志以 root 权限运行脚本。

    使用this issue 中的最后一条评论得到提示,然后导致“权限被拒绝错误”——因此是不安全的烫发。

    作为参考,我还有以下 Elasticbeanstalk 设置,这显然不足以 npm install everything...:

    /.ebextensions/00_change_npm_permissions.config

    files:
      "/opt/elasticbeanstalk/hooks/appdeploy/post/00_set_tmp_permissions.sh":
        mode: "000755"
        owner: root
        group: root
        content: |
          #!/usr/bin/env bash
          chown -R nodejs:nodejs /tmp/.npm 
    

    .npmrcpackage.json在同一目录中

    # Force npm to run node-gyp also as root, preventing permission denied errors in AWS with npm
    unsafe-perm=true
    

    【讨论】:

      猜你喜欢
      • 2020-02-19
      • 2017-01-22
      • 2021-11-26
      • 2020-08-31
      • 2015-05-07
      • 2015-07-17
      • 2020-06-08
      • 2019-02-22
      • 2021-02-03
      相关资源
      最近更新 更多