安装pecl
apt-get install -y php-pear
安装phpize
apt-get install -y php7.0-dev
安装grpc扩展
有扩展包
pecl install /tmp/grpc-1.14.0.tgz
无扩展包
pecl install grpc
在php.ini
中添加
extension=grpc.so
Build process completed successfully
Installing '/usr/lib/php/20151012/grpc.so'
install ok: channel://pecl.php.net/grpc-1.14.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=grpc.so" to php.ini
安装protoc扩展
有扩展包
pecl install /tmp/protobuf-3.6.0.tgz
无扩展包
sudo pecl install protobuf
在php.ini
中添加
extension=protobuf.so
Build process completed successfully
Installing '/usr/lib/php/20151012/protobuf.so'
install ok: channel://pecl.php.net/protobuf-3.6.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=protobuf.so" to php.ini
安装protobuf-php、grpc_php_plugin
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protobuf-php-3.6.1.tar.gz
tar -zxvf protobuf-php-3.6.1.tar.gz
cd protobuf-php-3.6.1
./configure --prefix=/usr/src
make && make install
$ cd /var
$ git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc
$ cd grpc
$ git submodule update --init
$ make grpc_php_plugin
protoc --proto_path=./ --php_out=./ --grpc_out=./ --plugin=protoc-gen-grpc=/var/grpc/bins/opt/grpc_php_plugin ./../protos/helloworld.proto