安装phantomjs



Linux

For Ubuntu Linux (tested on a barebone install of Ubuntu 10.04 Lucid Lynx, Ubuntu 11.04 Natty Narwhal, Ubuntu 12.04 Precise Pangolin):

sudo apt-get update
sudo apt-get install build-essential chrpath git-core libssl-dev libfontconfig1-dev
git clone git://github.com/ariya/phantomjs.git
cd phantomjs
git checkout 1.9
./build.sh
sudo apt-get install phantomjs
[sudo] password for liuken:
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
下列【新】软件包将被安装:
  phantomjs
升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 537 个软件包未被升级。
需要下载 186 kB 的软件包。
解压缩后会消耗掉 474 kB 的额外空间。
获取:1 http://cn.archive.ubuntu.com/ubuntu/ precise/universe phantomjs amd64 1.4.0+dfsg-1 [186 kB]
下载 186 kB,耗时 0秒 (640 kB/s)
Selecting previously unselected package phantomjs.
(正在读取数据库 ... 系统当前共安装有 218261 个文件和目录。)
正在解压缩 phantomjs (从 .../phantomjs_1.4.0+dfsg-1_amd64.deb) ...
正在设置 phantomjs (1.4.0+dfsg-1) ...
liuken@liuken-MS-7798:~$ phantomjs

Usage: phantomjs [options] script.[js|coffee] [script argument [script argument ...]]

Options:

--cookies-file=/path/to/cookies.txt    Sets the file name to store the persistent cookies
--config=/path/to/config               Specifies path to a JSON-formatted config file
--disk-cache=[yes|no]                  Enables disk cache (at desktop services cache storage location, default is 'no')
--ignore-ssl-errors=[yes|no]           Ignores SSL errors (i.e. expired or self-signed certificate errors)
--load-images=[yes|no]                 Loads all inlined images (default is 'yes')
--load-plugins=[yes|no]                Loads all plugins (i.e. 'Flash', 'Silverlight', ...) (default is 'no')
--local-to-remote-url-access=[yes|no]  Local content can access remote URL (default is 'no')
--max-disk-cache-size=size             Limits the size of disk cache (in KB)
--output-encoding                      Sets the encoding used for terminal output (default is 'utf8')
--proxy=address:port                   Sets the network proxy (e.g. "--proxy=192.168.1.42:8080")
--proxy-type=[http|socks5]             Sets the proxy type, either "http" (default) or "socks5"
--script-encoding                      Sets the encoding used for the starting script (default is 'utf8')
--version                              Prints out PhantomJS version

liuken@liuken-MS-7798:~$ cd phantomjs
liuken@liuken-MS-7798:~/phantomjs$ phantomjs test.js


### 编译并安装PhantomJSARM架构 对于在ARM架构上编译和安装PhantomJS,由于官方已经停止维护该项目,并不再提供预构建二进制文件的支持,因此需要从源码开始自行编译。这涉及到获取必要的依赖项以及遵循特定的指令来完成整个过程。 #### 准备工作环境 确保目标设备运行的是支持多线程处理的操作系统版本,并拥有足够的磁盘空间用于下载、解压和编译操作。更新现有软件包列表至最新状态[^1]: ```bash sudo apt-get update && sudo apt-get upgrade -y ``` #### 安装必需组件 为了能够成功编译PhantomJS,在ARM平台上需先安装一系列开发工具链和其他依赖库。这些通常包括但不限于Git、GCC/G++编译器套件、Python解释器及其相关模块等[^2]: ```bash sudo apt-get install build-essential g++ flex bison libqt4-dev libicu-dev libfontconfig1-dev libfreetype6-dev libpng-dev cmake python ruby git-core -y ``` #### 获取PhantomJS源代码 通过克隆GitHub仓库获得最新的稳定版源码副本。考虑到项目已终止活跃开发阶段,建议选择最后一个正式发布的标签页作为基础进行后续步骤[^3]: ```bash git clone https://github.com/ariya/phantomjs.git cd phantomjs git checkout tags/2.1.1 # 或者其他指定版本号 ``` #### 配置与编译流程 进入源目录后执行配置脚本以适应当前硬件平台特性;接着启动实际编译进程。注意此环节可能耗时较长取决于具体机器性能表现情况[^4]: ```bash ./build.sh --confirm --jobs=$(nproc) ``` 上述命令中的`--jobs=$(nproc)`参数允许利用全部可用CPU核心加速任务进度。如果遇到内存不足等问题,则可以适当减少并发作业数量直至顺利完成为止。 #### 执行测试案例验证功能正常性 编译完成后可选地运行内置单元测试集检验是否存在潜在缺陷影响正常使用体验。该部分并非强制要求但推荐实施以便提前发现问题所在[^5]: ```bash ./bin/phantomjs examples/basic_usage.js ``` #### 正式部署到系统路径下 最后一步就是把生成好的可执行文件复制到全局可见的位置方便日后调用访问。一般情况下会将其放置于`/usr/local/bin`这样的标准位置之上[^6]: ```bash sudo cp bin/phantomjs /usr/local/bin/ ``` 此时即代表已经在ARM架构计算机上面完成了PhantomJS的手动编译与安装全过程。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值