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.
May you just need to install this using a ppa package like:
sudo apt-get install php7.1-redis