Today's Question:  What does your personal desk look like?        GIVE A SHOUT

Install and enable redis extension in PHP 5.X on Windows

  sonic0002        2021-07-11 03:52:18       5,208        4    

Redis is frequently used as a caching layer for web applications to improve its performance. In PHP 5.x, if one wants to use Redis, the redis extension needs to be installed and enabled first.

This post will show how to install and enable redis extension on Windows with PHP 5.X. Basically there are two dlls to be downloaded: php_redis.dll and php_igbinary.dll.

Below are detailed steps

  1. Go to http://windows.php.net/downloads/pecl/releases/redis/2.2.7/ and find the respective php_redis zip matching your environment.
  2. Go to windows.php.net - /downloads/pecl/releases/igbinary/2.0.1/ and find the respective php_igbinary zip matching your environment
  3.  Unzip these two files and copy them to the ext folder of PHP.
  4. Next step is to update the php.ini file so that it can be loaded and enabled once the Apache server restarts. Below needs to be added in the php.ini file. (Note: The order matters here, php_igbinary.dll should come before php_redis.dll).
    extension=php_igbinary.dll
    extension=php_redis.dll​
  5. Save php.ini and now restart the Apache server and you should see Redis extension shown up in phpinfo().
  6. Now you can write code to access Redis server like below.
    $redis = new Redis();
    
    //Connecting to Redis
    $redis->connect('localhost', 6357);
    $redis->auth('password');
        
    if ($redis->ping()) {
        echo "OK";
    }​

Hope this helps you if you wanna use Redis in your PHP application.

PHP  WINDOWS  REDIS  PHP 5.6 

Share on Facebook  Share on Twitter  Share on Weibo  Share on Reddit 

  RELATED


  4 COMMENTS


Anonymous [Reply]@ 2021-07-11 18:17:28

PHP 5.x

What year is this?

Ke Pi [Reply]@ 2021-07-13 00:04:48

YOu r right, ppl shouldn't use this anymore. However, there are still some sites not migrated yet and may have the need.

Anonymous [Reply]@ 2022-11-15 06:08:14

Fatal error: Uncaught Error: Class "Redis" not found

When i try to run the php file it will come error. Then inside of the phpredis folder side also. If know any idea without to run the file on in the folder.

Ke Pi [Reply]@ 2022-11-16 04:26:05

think u r not using php 5.x compatible lib?