Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run phantomjs on heroku?

I am trying to run phantomjs on the heroku cedar stack.

I am using a phantomjs buildpack for heroku https://github.com/stomita/heroku-buildpack-phantomjs. However I followed the instructions but still cannot make it work. When I run the command heroku run bash and type phantomjs --version it says phantomjs: command not found

I read things about LD_LIBRARY_PATH that needs to be set to "/usr/local/lib:/usr/lib:/lib:/app/vendor/phantomjs/lib", this is what i did but without success.

Is there something that i am missing ? Where does the buildpack install the phantomjs binary exactly ? Is there a way to know the path where the binary is ?

I am using ruby 1.9.2

Thanks a lot for your help.

EDIT: To be more precise, i want to combine ruby and phantomjs, so i am using this custom buildpack: https://github.com/ddollar/heroku-buildpack-multi, but when i push to heroku i get "Heroku push rejected, failed to compile Multipack app"

like image 531
mathieurip Avatar asked Sep 19 '12 13:09

mathieurip


2 Answers

Download the 64-bit linux binary file from phantomjs.org here http://phantomjs.org/download.html

Create a bin/ directory in your app if you do not already have one and place the binary file there. You should then be able to test if you can run it with "heroku run 'phantomjs'" or "heroku run 'bin/phantomjs'"

like image 97
user1071182 Avatar answered Nov 19 '22 18:11

user1071182


For phantomjs with javascript

I dont know if the previous examples are actually necessary becasue although i am working with javascript it should not be different. For me all i had to do was place the phantomjs buildpack as the first on the list of installed buildpacks on your master.

check available buildpacks

open terminal from the app folder and type:

heroku buildpacks

This wll show the available buildpacks. eg.

1.heroku/node.js

2.https://github.com/stomita/heroku-buildpack-phantomjs.git

As you can see the buildpack is second on this list. We need tomake it the first in the list.So, what i did was i removed the phantomjs builpack and then add it again but this time made sure its first on the list of all available buildpacks.

So, to remove a buildpack, type:

heroku buildpacks:remove https://github.com/stomita/heroku-buildpack-phantomjs.git

this removes the buildpack.You can check it by typing:

heroku buildpacks

Now, it should only show,

1.heroku/node.js

Great, now we add the phantomjs buildackmaking sure its first . So on terminal type:

heroku buildpacks:add --index 1 https://github.com/stomita/heroku-buildpack-phantomjs.git

You can check if its first by typing:

heroku buildpacks

Now, it should be ,

1.https://github.com/stomita/heroku-buildpack-phantomjs.git
2.heroku/node.js

Thats It!!

now, on terminal , type:

heroku run bash

once you're in bash, type

phantomjs --version

The current verion of phantomjs should be shown on the terminal.

2.1.1
like image 1
John Yepthomi Avatar answered Nov 19 '22 17:11

John Yepthomi