linux安装PHP protobuf扩展

这几天在研究MQTT协议以及protobuf,现在做安装protobuf扩展,特此记录

 

php-protobuf仓库地址
https://github.com/allegro/php-protobuf

1、克隆代码

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


或是下载https://img2020.cnblogs.com/blog/969821/202112/969821-20211218142008890-910385489.jpg
修改文件名为php-protobuf-master.zip,并解压(因为不能上传文件,所以把文件后缀改成图片的方式上传了)

2、转到源代码目录

cd php-protobuf

3、构建并安装PHP扩展

$ phpize
$ ./configure
$ make
# make install

如果./configure报错:configure: error: Cannot find php-config. Please use --with-php-config=PATH
那么就是php-config文件位置不正确的原因

先查找php-config文件位置,例如我的文件位置是:/www/server/php/74/bin/php-config

那么./configure 改为:

./configure --with-php-config=/www/server/php/74/bin/php-config

并往下执行

$ make
# make install

修改php.ini配置,添加代码并重启PHP:

extension=protobuf.so

4、安装原型插件依赖

composer install

至此完成安装,phpinfo(); 查看是否已经安装

查看安装版本

/usr/local/protobuf/bin/protoc --version

5、添加环境变量

export PATH=$PATH:/usr/local/protobuf/bin

  



 



posted @ 2021-11-15 23:48  智昕  阅读(502)  评论(0)    收藏  举报