Skip to content

Instantly share code, notes, and snippets.

@alfianmalik
Last active December 11, 2021 22:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alfianmalik/463251cb5be13012b6646eb5fe13c6ed to your computer and use it in GitHub Desktop.
Save alfianmalik/463251cb5be13012b6646eb5fe13c6ed to your computer and use it in GitHub Desktop.
how to install protobuf + grpc + php on ubuntu

Hello, i am try to install protobuf + grpc + php, here is how i do

sudo apt install php-dev protobuf-compiler protobuf-compiler-grpc
sudo pecl channel-update pecl.php.net
sudo pecl install grpc protobuf

sudo -i
cd /etc/php/7.1/mods-available  
echo "extension=protobuf.so" > protobuf.ini
echo "extension=grpc.so" > grpc.ini
phpenmod grpc protobuf    
php -r 'phpinfo();' | grep -i "\(grpc\|protobuf\)"

Have fun

If you success, you will see

/etc/php/7.1/cli/conf.d/20-grpc.ini,
/etc/php/7.1/cli/conf.d/20-protobuf.ini,
grpc
grpc support => enabled
protobuf
@dadinugroho
Copy link

Hi @alfianmalik

I got this issue when running sudo pecl install grpc protobuf.

The environment is DigitalOcean droplet (the USD 5) with Ubuntu 20.04. It is PHP 7.4.

...
 g++ -fvisibility=hidden -DOPENSSL_NO_ASM -D_GNU_SOURCE -DWIN32_LEAN_AND_MEAN -D_HAS_EXCEPTIONS=0 -DNOMINMAX -DGRPC_ARES=0 -DGRPC_POSIX_FORK_ALLOW_PTHREAD_ATFORK=1 -DGRPC_XDS_USER_AGENT_NAME_SUFFIX=\"PHP\" -DGRPC_XDS_USER_AGENT_VERSION_SUFFIX=\"1.42.0\" -I. -I/tmp/pear/temp/grpc -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootKvCDcG/grpc-1.42.0/include -I/tmp/pear/temp/pear-build-rootKvCDcG/grpc-1.42.0/main -I/tmp/pear/temp/grpc -I/usr/include/php/20190902 -I/usr/include/php/20190902/main -I/usr/include/php/20190902/TSRM -I/usr/include/php/20190902/Zend -I/usr/include/php/20190902/ext -I/usr/include/php/20190902/ext/date/lib -I/tmp/pear/temp/grpc/include -I/tmp/pear/temp/grpc/src/core/ext/upb-generated -I/tmp/pear/temp/grpc/src/core/ext/upbdefs-generated -I/tmp/pear/temp/grpc/src/php/ext/grpc -I/tmp/pear/temp/grpc/third_party/abseil-cpp -I/tmp/pear/temp/grpc/third_party/address_sorting/include -I/tmp/pear/temp/grpc/third_party/boringssl-with-bazel/src/include -I/tmp/pear/temp/grpc/third_party/re2 -I/tmp/pear/
temp/grpc/third_party/upb -I/tmp/pear/temp/grpc/third_party/xxhash -DHAVE_CONFIG_H -std=c++11 -fno-exceptions -fno-rtti -g -O2 -c /tmp/pear/temp/grpc/src/core/ext/xds/xds_client.cc  -fPIC -DPIC -o src/core/ext/xds/.libs/xds_client.o
g++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
make: *** [Makefile:828: src/core/ext/xds/xds_client.lo] Error 1
ERROR: `make' failed

Any help on this?

TIA

Daniel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment