写在前面
如果不是在纯内网用, 笔者是不推荐用Yar的。因为源码里面看,基本都是在封装curl。
php7.0+的yar
yar的git地址:https://github.com/laruence/yar
先克隆 如果没有 git 需要先安装
yum install git
然后 克隆
git clone https://github.com/laruence/yar.git
然后 进入yar 目录
cd yar
开始编译安装
[php安装路径]/bin/phpize ./configure --with-php-config=[php安装路径]/bin/php-config make && make install
然后把扩展添加到 php配置文件中, 例如
cd [php配置文件路径, 例如/usr/local/php/etc] vim php.ini
写入:
extension=yar.so
保存退出。
重启php nginx
php5.x的Yar
yar linux平台针对php5.x版本的兼容 http://pecl.php.net/get/yar-1.2.5.tgz
下载页面 http://pecl.php.net/package/yar
安装方法:
下载完yar-1.2.5.tgz这个包之后放到linux主机root文件夹下, 用以下命令解压:
# 假设你已经用ftp或者rz -E传好了yar-1.2.5.tgz这个文件 cd /root tar zxvf yar-1.2.5.tgz
之后同yar在php7.0的安装方法一样, 一套命令做下来:
cd yar-1.2.5 [php安装路径]/bin/phpize ./configure --with-php-config=[php安装路径]/bin/php-config make && make install vim [php配置文件路径]/php.ini
加入以下配置:
extension="yar.so"
报错解决
Cannot find config.m4.
Make sure that you run '/usr/local/php/bin/phpize' in the top level source directory of the module
很简单, 说明你没进yar的安装目录, 你需要先cd到yar的安装目录, 例如
cd yar-1.2.5
才可以