How to use PhantomJS 2.5.0 Beta on Heroku

我只是一个虾纸丫 提交于 2019-12-08 08:34:38

问题


Version 2.5.0 beta of PhantomJS is available for use, but unlike stable versions, there are some dependencies for linux installations. I'm having trouble getting a working version on Heroku. I couldn't find a guide or any real answers in the Google group or elsewhere. How can I go about getting the installation?


回答1:


Ultimately, I was able to figure it out! There are a few things that you have to do...

TL;DR:

  1. heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt
  2. heroku buildpacks:add https://github.com/lookitsatravis/heroku-buildpack-phantomjs.git
  3. cat > Aptfile << EOL webp libhyphen0 https://mirrors.kernel.org/ubuntu/pool/main/g/gcc-5/gcc-5_5.4.1-8ubuntu1_amd64.deb https://mirrors.kernel.org/ubuntu/pool/main/g/gcc-5/libstdc++6_5.4.0-6ubuntu1~16.04.4_amd64.deb EOL
  4. Commit Aptfile, push to Heroku app.

More info

  1. Dependencies: You have to use the Heroku Apt buildpack to install the missing dependencies. First, you need to add the buildpack to your app:

    heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt

    Next, you'll create a file in your project root called Aptfile. Here's where we add the missing dependencies for PhantomJS 2.5.0 Beta. 2.5.0 introduces webp support, so we need that. libhyphen0 is required as well, though I'm not sure how it us used. Finally, we use gcc-5 and the latest libstdc++6. Contents should look like this:

webp
libhyphen0
https://mirrors.kernel.org/ubuntu/pool/main/g/gcc-5/gcc-5_5.4.1-8ubuntu1_amd64.deb
https://mirrors.kernel.org/ubuntu/pool/main/g/gcc-5/libstdc++6_5.4.0-6ubuntu1~16.04.4_amd64.deb
  1. PhantomJS: Next we grab the latest version of PhantomJS. I've created a fork of the most popular PhantomJS buildpack and updated it for use with 2.5.0 beta. 2.5.0 beta has builds for trusty as well as xenial, so the build pack will detect the Heroku stack and use the appropriate one (though the cedar-16 stack is still in beta at the time of this post). So, add it to your app:

    heroku buildpacks:add https://github.com/lookitsatravis/heroku-buildpack-phantomjs.git

  2. Deploy: All that's left is deployment! Commit the Aptfile to your repo, make sure the build packs are setup, and then push to Heroku.

Took a bit of trial and error, but ultimately I was able to get it up and running. Hope this helps others until the final candidate is released.



来源:https://stackoverflow.com/questions/42878323/how-to-use-phantomjs-2-5-0-beta-on-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!