php扩展grpc(干货)

环境:centos7,php7

wget http://pecl.php.net/get/grpc-1.8.0.tgz

pecl install ./grpc-1.8.0.tgz 

echo "extension=grpc.so;" >> /etc/php7/php.ini

wget https://github.com/allegro/php-protobuf/archive/master.zip

unzip master.zip

cd php-protobuf-master

phpize

./configure

make

make install

echo "extension=protobuf.so" >> /etc/php7/php.ini

php -m(查看php插件列表)

 

docker 环境,构建镜像

注:docker镜像系统不同是请按需修改相关命令

vim Dockerfile

FROM nginx-php
MAINTAINER opsyang@unix.com

WORKDIR /home/grpc

RUN apk upgrade --no-cache \
apk add git \
apk add vim \
apk add net-tools telnet \
apk add which \
apk add autoconf libtool ruby \
apk add make \
apk add gcc gcc-c++ kernel-devel build-essential libgflags-dev libgtest-dev clang libc++-dev zlib

RUN /bin/sh -c 'wget http://pecl.php.net/get/grpc-1.8.0.tgz' ##gepc扩展

RUN /bin/sh -c 'pecl install ./grpc-1.8.0.tgz && echo "extension=grpc.so;" >> /etc/php7/php.ini'

RUN /bin/sh -c 'wget https://github.com/allegro/php-protobuf/archive/master.zip && unzip master.zip && cd php-protobuf-master && phpize && ./configure && make && make install && echo "extension=protobuf.so" >> /etc/php7/php.ini'  ##protobuf扩展

RUN /bin/sh -c 'php -m'

注:环境版本不同,需要不同的安装依赖

posted @ 2020-10-30 13:28  木易--  阅读(217)  评论(0编辑  收藏