Php extension php-redis installation and use, php extension php-redis
I. redis Installation
1. Install the redis version.
Download Page: https://redis.io/download
Install an old version 3.2.11: http://download.redis.io/releases/redis-3.2.11.tar.gz
2. After wget is downloaded, decompress the package, cd to the decompressed directory, and then make & sudo make install to complete the installation.
3. Start:
In the source package directory, cd to the src directory and start the server:src/redis-server,
Start the client:
src/redis-cli
Ii. php-redis extension Installation
1. Download Extension: https://github.com/phpredis/phpredis/tree/master
2. unzip: unzip phpredis-master.zip
3. cd phpredis-master
4. Execute the phpize plug-in module of the corresponding php version,/usr/local/php54/bin/phpize
5,
./Configure -- with-php-config =/usr/local/php54/bin/php-config
Make & sudo make install
6. Load the extension in the php. ini file
Extension = redis. so
So far, php-redis extension installation is complete
3. Write a simple test file
ghostwu@ghostwu:~/php/php_redis$ cat redis_test1.php -n 1 <?php 2 $redis = new Redis(); 3 $redis->connect( "127.0.0.1", 6379 ); 4 $redis->set( "hi", "hello ghostwu" ); 5 echo $redis->get( "hi" ) . PHP_EOL; 6 ?>ghostwu@ghostwu:~/php/php_redis$ /usr/local/php54/bin/php -f redis_test1.php hello ghostwu
ghostwu@ghostwu:~/software/redis-3.2.11/src$ redis-cli127.0.0.1:6379> set foo barOK127.0.0.1:6379> get foo"bar"127.0.0.1:6379> get hi"hello ghostwu"127.0.0.1:6379> get hi"hello ghostwu"127.0.0.1:6379>