mac下安装php-grpc,php-protobuf扩展

1, 安装protobuf3

a,编译安装

git clone https://github.com/google/protobuf.git

cd protobuf

sh ./autogen.sh

./configure

make 

sudo make install

b,brew安装(推荐)

brew install protobuf

安装完成后,检查是否安装成功,执行命令 protoc --version 。若安装成功,可看到返回的版本号信息。

2, 安装php-protobuf扩展

git clone https://github.com/allegro/php-protobuf

phpize

./configure

make && make install

安装完成后,修改php.ini,添加配置 

extension = protobuf.so

执行命令 php -m | grep protobuf 查看是否安装成功。


grep

3, grpc扩展安装

git clone https://github.com/grpc/grpc

cd grpc

git submodule update --init --recursive   

make

make install

该步比较耗时,因为拉取子仓库的时候会非常久。。。项目刚pull下来就400+M,子项目来取完成以后,将近2G。。。

建议git submodule update --init --recursive 命令多执行两次,免得有的子项目么有拉取成功,进而造成编译失败!!!

另外,该步meke的时候,可能提示错误

Installing via 'make' is no longer supported. Use cmake or bazel instead.

可以参考以下操作,可以避免上述错误

git clone https://github.com/grpc/grpc

cd grpc

git submodule update --init --recursive  

mkdir -p cmake/build

cd cmake/build

cmake ../..

make

sudo make install

安装完成后,修改php.ini文件,增加配置

extension = grpc.so

4,系统安装grpc_php_plugin插件

接上一步操作,此时还在 cmake/build 文件夹下。

 make protoc grpc_php_plugin

你可能感兴趣的:(mac下安装php-grpc,php-protobuf扩展)