php安装grpc扩展的具体步骤

时间:2022-02-02 22:02:54

1、在php.ini文件中添加grpc扩展配置:extension=grpc.so

?
1
2
3
4
5
6
7
8
9
10
11
git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc
cd grpc
git submodule update --init
make
make install
cd src/php/ext/grpc
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
vi /usr/local/php/etc/php.ini

2、安装 protobuf及其php扩展

?
1
2
3
4
5
6
7
8
9
10
11
cd ../../../../third_party/protobuf
./autogen.sh
./configure
make
make install
cd php/ext/google/protobuf
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
vi /usr/local/php/etc/php.ini

3、重启php-fpm。

 安装中出现的问题:

结果报错了:

Error:src/core/lib/compression/message_compress.lo' failed

这个又是神马情况,在网上搜索了一通,原来是在编码的时候,虚招zlib发现没有这个文件,怎么办?装呗

?
1
apt-get install zlib1g-dev


 

然后在执行以下pecl install grpc发现居然安装上去了,根据安装提示需要将grpc.so添加到php.ini文件中方便查看;

?
1
echo "extension=grpc.so" >> /etc/php/7.2/cli/php.ini


 

记得重启下:service php7.2-fpm restart

查看模块: php -m | grep "grpc"

至此,这个grpc安装完成了!

到此这篇关于php安装grpc扩展的具体步骤的文章就介绍到这了,更多相关php安装grpc扩展的方法内容请搜索服务器之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持服务器之家!

原文链接:https://www.py.cn/php/jiaocheng/31396.html