本文实例讲述了php7安装yar扩展的方法。分享给大家供大家参考,具体如下:
体验RPC框架Yar需要:
1. 装二进制打包协议msgpack
2. 装yar拓展和依赖
一. 安装二进制打包协议msgpack
1. 安装PHP拓展包有很多种方式,当然没什么是比pecl更加来得暴力,用这个之前要确认phpize是否存在
find / -name phpize
2. 如果phpize不存在
yum install php-devel
3. Ok,先装msgpack
pecl install msgpack
安装跳了一大堆编译过程过程,省略ING 只关心后几行
Build process completed successfully Installing '/usr/include/php/ext/msgpack/php_msgpack.h' Installing '/usr/lib64/php/modules/msgpack.so' install ok: channel://pecl.php.net/msgpack-0.5.6 configuration option "php_ini" is not set to php.ini location You should add "extension=msgpack.so" to php.ini
安装完 msgpack.so 会自动复制到 php 扩展库,并写好配置。
二. 安装 yar
1. 下载 yar
wget http://pecl.php.net/get/yar-2.0.0.tgz
2. 解压编译
tar -zxvf yar-2.0.0.tgz cd cd yar-2.0.0 /usr/bin/phpize ./configure --with-php-config=/usr/bin/php-config7.0*
遇到问题:
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution - easy.h should be in <curl-dir>/include/curl/
3. 安装 curl-devel
yum -y install curl-devel sudo apt-get install libcurl4-gnutls-dev
ps:curl vs curl-deval
参考: http://stackoverflow.com/questions/4976971/compiling-php-with-curl-where-is-curl-installed
4. 安装 yar
make && make install
5. 复制 yar.so 到 php 扩展库下
sudo cp yar.so /usr/lib/php/20151012/yar.so
6. 扩展写配置文件
echo "extension=yar.so" > /etc/php/7.0/mods-available/yar.ini ln -sf /etc/php/7.0/mods-available/yar.ini /etc/php/7.0/fpm/conf.d/20-yar.ini ln -sf /etc/php/7.0/mods-available/yar.ini /etc/php/7.0/cli/conf.d/20-yar.ini
7. 重启 php-fpm nginx
service php7.0-fpm restart service nginx restart
ps: php -ir 查询 phpinfo
希望本文所述对大家PHP程序设计有所帮助。