Skip to content
Advertisement

gRPC extension not installed in the right PHP version in Ubuntu 18.04

I’m trying to install gRPC extension following the official guidance

I’ve followed all the steps, but on these final steps, I get this (which I think will matter later)

$ cd grpc/src/php/ext/grpc
$ phpize
$ ./configure
$ make
$ sudo make install

Installing shared extensions: /usr/lib/php/20190902/

Here, I checked that folder and found the grpc.so file.

At this point, I expected to have the extension installed, I’ve added extension=grpc.so within php.ini (apache2 and cli). But it doesn’t work.

I tried to verify it but it returns false: var_dump(extension_loaded('grpc')); => bool(false)

Now, I’ve checked the apache2 log file and I saw this:

PHP Warning: PHP Startup: Unable to load dynamic library ‘grpc.so’ (tried: /usr/lib/php/20180731/grpc.so (/usr/lib/php/20180731/grpc.so: cannot open shared object file: No such file or directory), /usr/lib/php/20180731/grpc.so

The possible error?

What I think is, after install the grpc extension it was installed in /usr/lib/php/20190902/ (as you saw before). But apache is trying to find it in /usr/lib/php/20180731/grpc.so

I don’t know what I’m doing wrong. I think I edited the right php.ini files because when I do php_info() I get this:

Configuration File (php.ini) Path   /etc/php/7.3/apache2
Loaded Configuration File   /etc/php/7.3/apache2/php.ini
Scan this dir for additional .ini files /etc/php/7.3/apache2/conf.d

Advertisement

Answer

I’ve solved it. Apparently pecl needed to be configurated on what PHP version I wanted it to be installed. Something like this, it was being installed on the latest version I have, the 7.4. But I needed it to be in the 7.3 version:

# cd ./grpc

# phpize7.3

# ./configure --with-php-config=/usr/bin/php-config7.3

# make clean

# make

# make install
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement