Home  >  Article  >  Backend Development  >  Detailed explanation of the steps to install protobuf in PHP

Detailed explanation of the steps to install protobuf in PHP

藏色散人
藏色散人forward
2021-03-18 16:35:384126browse

Detailed explanation of the steps to install protobuf in PHP

php install protobuf

This article uses the vagrantbox virtual machine installed under windows

Using vagrant Connection

The mirror environment is centos-release-7-9.2009.1.el7.centos.x86_64

1. First go to the official website to download the protobuf file
https://github.com/ protocolbu...

Choose a php language to download
![Uploading...]()

Detailed explanation of the steps to install protobuf in PHP

You can choose any one, What I chose here is the

at the end of tar.gz 2. Put the package into the virtual machine

3. Unzip
tar zxvf protobuf-2.6.1.tar. gz

4. Enter the decompressed folder to install

For example, here is the decompressed 2.6.1 package, and the folder I decompressed is protobuf-2.6. 1

cd protobuf-2.6.1/
./configure --prefix=/usr/local/protobuf
make && make install
export PATH=/usr/local/protobuf/bin/protoc

5. After the installation is completed, check whether the installation is successful. The following interface appears to indicate success. If not, check the reason for the error, and then reinstall

protoc --version

6. Install PHP extension

There are two PHP extensions First installation method

.解压安装

    1.去PHP的PECL网站下载扩展
        http://pecl.php.net/package/protobuf
    
    2.将扩展包放入虚拟机
    
    3.解压扩展包
    
    4.进入文件夹,执行安装命令
        phpize
        ./configure --with-php-config=/usr/local/php/bin/php-config 
        make && make install
        
    5.编辑本机php.ini文件
        找不到位置的可通过如下命令找到文件
        php --ini
![image.png](/img/bVcQznH)

    6.进入编辑模式,增加如下一行到文件末尾
        extension=protobuf.so
    
    7.通过以下命令查看是否安装成功
        ![image.png](/img/bVcQznW)

2. Command installation

1.直接执行以下命令即可

    pecl install protobuf
    
2.从上面解压安装的第5步继续往下安装扩展

At this point, the installation is complete.

The above is the detailed content of Detailed explanation of the steps to install protobuf in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete