Installing phpredis on Ubuntu 14.04 for PHP 7.1
Asked Answered
K

2

6

My php -v

PHP 7.1.15-1+ubuntu14.04.1+deb.sury.org+2 (cli) (built: Mar 6 2018 11:51:39) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans with Zend OPcache v7.1.15-1+ubuntu14.04.1+deb.sury.org+2, Copyright (c) 1999-2018, by Zend Technologies

I have tried both the pecl way

sudo pecl install redis
sudo service php7.1-fpm restart

And the manual way from https://github.com/phpredis/phpredis

phpize
./configure [--enable-redis-igbinary]
make && make install

I made sure to put

extension=/usr/lib/php/20170718/redis.so

into the php.ini file as shown when I run echo phpinfo();

e.g.

/etc/php/7.1/cli/php.ini

When I run the inbuilt web server I get

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20170718/redis.so' - /usr/lib/php/20170718/redis.so: undefined symbol: zend_empty_string in Unknown on line 0

Strangely PHPStorm autocompletes the PHP Redis class, so

$redis = new \Redis();
$redis->connect('127.0.0.1', 6379);

I can click into the Redis class and see it is the correct one.

I wonder if it is a version difference? Maybe because I am using 32-bit?

Another strange thing is, if I just put

extension=redis.so 

in php.ini, it seems to be looking for an older build

PHP Startup: Unable to load dynamic library '/usr/lib/php/20160303/redis.so' - /usr/lib/php/20160303/redis.so: cannot open shared object file: No such file or directory in Unknown on line 0

When I run

sudo apt-get install php-redis

it installs and means that no start up error shows, but the web page still shows a

Class 'Redis' not found

One other thing I notice is that in Apache, there is no error, and the class is found. But when I run php's inbuilt web server, the not found error shows up.

Keepsake answered 2/4, 2018 at 16:49 Comment(0)
G
21

May you just need to install this using a ppa package like:

sudo apt-get install php7.1-redis
Gunsmith answered 12/4, 2018 at 3:32 Comment(2)
Cheers for the answer, that is important, but I needed to remove 7.2 first.Keepsake
For beginners, you can change php7.1 with your php version.Cryometer
K
1

Ok so I noticed that phpinfo showed

PHP API 20160303

which means that the earlier error makes sense. The PHP version of the web server is 7.1, however, when running the phpredis phpize it shows the one for 7.2.

So I just made sure to remove php7.2-dev and re-install php7.1 via apt-get, then re-run the github repo steps above.

Keepsake answered 2/4, 2018 at 18:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.