yar 是鸟哥 使用C语言写的一款RPC框架 ,要使用yar 必须打扩展 .so 文件。
如何在Linux系统下安装yar的扩展,使php可以使用?
我们需要借助github
或者使用php
这个地址,进行下载
下载源码文件进行安装。
[root@localhost src]# wget https://pecl.php.net/get/yar-2.0.5.tgz
--2019-04-04 22:36:02-- https://pecl.php.net/get/yar-2.0.5.tgz
Resolving pecl.php.net... 104.236.228.160
Connecting to pecl.php.net|104.236.228.160|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 38004 (37K) [application/octet-stream]
Saving to: “yar-2.0.5.tgz”
100%[===================================================================================================================>] 38,004 144K/s in 0.3s
2019-04-04 22:36:04 (144 KB/s) - “yar-2.0.5.tgz” saved [38004/38004]
[root@localhost src]# tar -xf yar-2.0.5.tgz
[root@localhost src]# cd yar-2.0.5
[root@localhost yar-2.0.5]# ls
config.m4 LICENSE tests yar.c yar_exception.c yar_packager.h yar_request.c yar_response.h yar_transport.c
config.w32 packagers tools yar_client.c yar_exception.h yar_protocol.c yar_request.h yar_server.c yar_transport.h
CREDITS php_yar.h transports yar_client.h yar_packager.c yar_protocol.h yar_response.c yar_server.h
[root@localhost yar-2.0.5]#
#找到phpize
[root@localhost yar-2.0.5]# ls /usr/local/php/php7/bin/
pear peardev pecl phar phar.phar php php-cgi php-config phpdbg phpize
[root@localhost yar-2.0.5]# /usr/local/php/php7/bin/phpize
Configuring for:
PHP Api Version: 20170718
Zend Module Api No: 20170718
Zend Extension Api No: 320170718
[root@localhost yar-2.0.5]#
[root@localhost yar-2.0.5]#
[root@localhost yar-2.0.5]# ./configure --with-php-config=/usr/local/php/php7/bin/php-config
[root@localhost yar-2.0.5]# make && make install
[root@localhost yar-2.0.5]#
............
................
............
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php/php7/lib/php/extensions/no-debug-non-zts-20170718/
[root@localhost yar-2.0.5]#
[root@localhost yar-2.0.5]# ls /usr/local/php/php7/lib/php/extensions/no-debug-non-zts-20170718/
mongodb.so opcache.a opcache.so openssl.so pcntl.so phalcon.so redis.so swoole.so xhprof.so yaf.so yar.so zlib.so
至此安装完成
配置php.ini 文件
我的php文件放在 /usr/local/php/php7/etc 这个目录下,直接打开,进行修改
至此,安装完成,重新启动php 即可。
重启过程:我本地把php7 建立了一个 service 的脚本命令,
[root@localhost yar-2.0.5]# service phpfpm7 restart
Gracefully shutting down php-fpm . done
Starting php-fpm done
这样我就启动完成了。
重新检测php是否支持yar的扩展[root@localhost yar-2.0.5]# php -m | grep yar
yar