PHP 安装 gRPC

2023-08-23 18:47:30 浏览数 (1)

ENV

代码语言:javascript复制
cat /etc/redhat-release

CentOS Linux release 7.2 (Final)

uname -a
Linux xxx-xxx 3.10.107-1-tlinux2_kvm_guest-0052 #1 SMP Wed Jan 15 18:42:19 CST 2020 x86_64 x86_64 x86_64 GNU/Linux

PECL

代码语言:javascript复制
pecl install grpc

如果遇到:

代码语言:javascript复制
Connection to `ssl://pecl.php.net:443′ failed:

参考:

PHP Swoft 框架环境配置 | ZYF.IM

Build

通用手动安装 PECL 扩展

For this to work, you’ll need to have root access to your server, and you’ll most probably need developer tools installed as well.

https://pecl.php.net/

代码语言:javascript复制
# 创建临时目录
mkdir /tmp/download/ && cd /tmp/download/
# 下载
wget http://pecl.php.net/get/[extension].tgz
# 解压
tar -xvf [extension].tgz
cd [extension]
# 配置
phpize
# 查看参数
./configure --help
# 设置参考 以实际情况为准
./configure --enable-[extension]
# 编译
make && make test
# 安装
make install
# 查看 ini 路径
php --ini
# 开启
vi [php-ini].ini
extension=[extension].so

gcc is currently not installed

代码语言:javascript复制
yum install gcc

...already installed and latest version...

gcc

...gcc is currently not installed.

yum reinstall gcc
# 重新安装后解决

GrpcLb::TokenAndClientStatsAttribute::ToString() const

原因:gcc 版本过低。

代码语言:javascript复制
yum install centos-release-scl

yum install devtoolset-8-gcc*

scl enable devtoolset-8 bash

source /opt/rh/devtoolset-8/enable

References

  • 安装适用于 PHP 的 gRPC | cloud.google
  • PHP 安装 grpc 扩展报错 | jianshu

– EOF –

  • # php

0 人点赞