寫在前面
如果不是在純内網用, 筆者是不推薦用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
才可以