Home » Php » PHP redis error

PHP redis error

Posted by: admin July 12, 2020 Leave a comment


I installed the php redis extension. But when I run the test code, I got the following error:

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/redio.so' - /usr/lib/php5/20090626+lfs/redio.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Fatal error:  Class 'Redis' not found in /var/www/test/redisTest.php on line 2

My php version is 5.3.10, I installed the new version of phpredis.

May I get your help?

The install steps are:

git clone https://github.com/nicolasff/phpredis.git
cd phpredis
make install

Then add a config file in /etc/php5/fpm/confi.d to load redis.so

How to&Answers:

I use PHP 5.3 and installing PHP-Redis using below steps worked just fine for me:

  • Install pecl extension
    sudo pecl install redis
  • In php.ini, you may need set extension_dir to correct value. (can be usr/lib64/php/modules as above command placed the redis.so in this directory). In my case, I didn’t set this.
  • Add below line to php.ini:
  • Restart Apache/PHP-FPM


To verify if you have got redis installed you can do this

php -m | grep redis


Create a file PHP with echo phpinfo(); in it and see if the module is showing up. If you do not see the module then it is not being loaded correctly.


In the PHP5.3 and Amazon Linux AMI (Same as Centos OS 5)

install libs

yum install php-pear php-devel make gcc wget

install redis

cd /opt/
mkdir /opt/redis
wget https://redis.googlecode.com/files/redis-2.6.14.tar.gz "or last version"
tar -zxvf redis-2.6.14.tar.gz
cd redis-2.6.14
make install

install php-redis by pecl

pecl install redis

configuration option “php_ini” is not set to php.ini location

You should add “extension=redis.so” to php.ini

reload the web service httpd

service httpd reload

verify that the extension has been installed

php -m
[PHP Modules]
[Zend Modules]


Download the proper library file according to your server environment( ex. x86). also, check for your PHP is thread-safe or not and download the Redis library accordingly. then place the library file inside the extension folder. you need to mention the library inside your php.ini as given below.


then restart the server once, and check it’s working properly or not.
if you have command line PHP, you can check it in the command line PHP as,

php r("print_r(get_loaded_extensions());")