HOW TO INSTALL PHANTOMJS ON A CENTOS SERVER

本文详细介绍了如何在CentOS服务器上安装PhantomJS,并解决了安装过程中遇到的缺少依赖库问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

转自:http://www.sameerhalai.com/blog/how-to-install-phantomjs-on-a-centos-server/

I was playing around with using a server to run end to end scenario testing using PhantomJs(new to it, check out some useful books here). I like that PhantomJs has minimal requirements. However, I did have to install a couple of libraries that I didn’t find clear documentation for. So to benefit anyone who might be trying to do this, here are my steps:

Download Phantom

[samh@do ~]$ curl -O https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-i686.tar.bz2
 % Total % Received % Xferd Average Speed Time Time Time Current
 Dload Upload Total Spent Left Speed
100 13.0M 100 13.0M 0 0 2908k 0 0:00:04 0:00:04 --:--:-- 3402k

Extract directory

[samh@do ~]$ tar xvf phantomjs-1.9.1-linux-i686.tar.bz2

Copy binary to bin folder (note you may need to use sudo if you are not logged in with root priveleges)

[samh@do ~]$ cp phantomjs-1.9.1-linux-i686/bin/phantomjs /usr/local/bin

You will notice that this is not enough to run Phantom and you will encounter this error:

[samh@do ~]$ phantomjs hello.js
phantomjs: error while loading shared libraries: libfreetype.so.6: cannot open shared object file: No such file or directory

Here is the step to eliminate it:

[samh@do ~]$ sudo yum install freetype

Then you will see another error:

[samh@do ~]$ phantomjs hello.js
phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

And here’s how to eliminate it:

[samh@do ~]$ sudo yum install fontconfig

This is it. Everything should work now:

[samh@do ~]$ phantomjs hello.js
Hello, world!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值