美文网首页
gRPC安装与编译

gRPC安装与编译

作者: 烦热海 | 来源:发表于2022-07-20 16:35 被阅读0次

    1.安装gRPC

    下载解压 grpc
    cd ~
    wget http://pecl.php.net/get/grpc-1.39.0.tgz
    tar xvf grpc-1.39.0.tgz
    cd grpc-1.39.0
    生成配置并编译安装(编译安装时间较长, 耐心等待)
    /www/server/php/74/bin/phpize
    ./configure --with-php-config=/www/server/php/74/bin/php-config
    make && make install
    配置PHP扩展, 重启PHP服务, 清理下载文件
    echo "extension = grpc.so" >> /www/server/php/74/etc/php.ini
    /etc/init.d/php-fpm-74 reload
    /www/server/php/74/bin/php -m|grep -i  gRPC
    cd .. && rm -rf grpc-1.39.0*
    

    grpc与protobuf版本对照表:https://github.com/grpc/grpc/tree/v1.38.1/src/php

    2.生成grpc_php_plugin

    git clone  https://github.com/grpc/grpc
    cd grpc
    # 如果子模块更新进度卡顿,可以切换项目访问地址
    git submodule update --init
    # 切换项目访问地址后执行
    git submodule update --init --recursive
    mkdir -p cmake/build
    cd cmake/build
    cmake ../..
    make protoc grpc_php_plugin
    cp ./grpc_php_plugin /usr/local/bin/
    

    切换项目访问地址:
    url信息都在.gitmodules文件,一般是在项目根目录,将url路径切换为github镜像地址:http://git.what996.com

    相关文章

      网友评论

          本文标题:gRPC安装与编译

          本文链接:https://www.haomeiwen.com/subject/nntyirtx.html