Take Linux for example, first download PHP expansion module, address Ps://github.com/nicolasff/phpredis ">https://github.com/nicolasff/phpredis, After the download completes the decompression operation first, tar zxvf phpredis.tar.gz
CD phpredis-master/
/usr/local/webserver/php/bin/phpize
./configure--with-php-config=/usr/local/webserver/php/bin/php-config
Make
Make install
Vi/usr/local/webserver/php/etc/php.ini
Extension = redis.so
Restart Apache or PHP-FPM
Check out phpinfo should see Redis extension
Windows Redis extended Download Address https://github.com/nicolasff/phpredis/downloads, select the corresponding version of the download can be.
After you set up your PHP extensions, write code to test it:
$redis = new Redis ();
$redis->connect (' localhost ', 6379);
$redis->set (' key ', ' Zhangsan '); Setting values
$res = $redis->get (' key ');
Echo $res;
$id = $redis->incr (' id ')/self-increasing
$redis->hmset ($id, Array (' User ' => ' zhangsan ', ' email ' => ' addd@ff.com '));
Print_r ($redis->hgetall (' 2 '));