‹ Articles

How to Install the PHP gRPC Extension

In the examples shown, replace "X.Y" with your app's PHP version (for example, "5.6" or "7.2"). To install a PECL extension for multiple PHP versions, repeat the PECL extension installation for each PHP version.
The gRPC extension requires Ubuntu 14.04, 16.04, or 18.04. This extension can't be installed on Ubuntu 12.04.

gRPC

Google's gRPC is a remote procedure call (RPC) system that communicates over HTTP/2, uses Protocol Buffers to serialize data, works across programming languages, and provides many other features such as pluggable authentication.

Installing gRPC on PHP 5.5+ or PHP 7.0+

To install this extension, run the following commands as your server's root user:

sudo apt-get -y install gcc g++ make autoconf libc-dev pkg-config
sudo apt-get -y install zlib1g-dev
sudo peclX.Y-sp install grpc

Once installed, create a configuration file for the extension and restart PHP by running the following commands as root:

sudo bash -c "echo extension=grpc.so > /etc/phpX.Y-sp/conf.d/grpc.ini"
sudo service phpX.Y-fpm-sp restart

Installing gRPC on PHP 5.4

The gRPC extension does not support PHP 5.4.

Verifying the Installation

You can verify the gRPC extension is installed correctly by running this command:

phpX.Y-sp -i | grep -i grpc

You should see output like the following:

grpc
grpc support => enabled
grpc module version => 1.9.0

Uninstalling the gRPC Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/grpc.ini
sudo peclX.Y-sp uninstall grpc

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

Last updated: April 26, 2018

Still Have Questions?

Don't hesitate to contact us if you can't find the answers to your questions.