1. Install redis under windows and test it
redis download address: https://github.com/dmajkic/redis/downloads
The downloaded Redis supports 32bit and 64bit. Choose according to your actual situation, I choose 32bit. Copy the 32bit file contents to the directory that needs to be installed, such as: D:devredis-2.4.5.
Open a cmd window, use the cd command to switch to the specified directory (D:devredis-2.4.5) and run redis-server.exe redis.conf. After running, the following interface will appear:
This means that the Redis server has been installed successfully.
Reopen a cmd window, use the cd command to switch to the specified directory (D:devredis-2.4.5) and run:
redis-cli.exe -h 127.0.0.1 -p 6379
where 127.0.0.1 is the local IP and 6379 is the default port of the redis server. The successful operation is as shown in the figure below. In this way, the establishment of Redis windows environment has been completed:
The environment has been set up, so you have to test it. For example: store a string with the key as test and the value as hello word, and then get the key value:
The hell word is correctly output, and the test is successful!
2. Installation and use of Redis extension in PHP
Download the php_redis.dll file: http://download.csdn.net/download/bluesky321/5355093
First put php_redis.dll and php_igbinary.dll into PHP ext folder, and then add the following code to the php.ini configuration file:
extension=php_igbinary.dll extension=php_redis.dll
Restart the web server
Note: extension=php_igbinary.dll must be placed in front of extension=php_redis.dll, otherwise this extension will not take effect
Use:
<?php $redis = new Redis(); $redis->connect('127.0.0.1',6379); $redis->set('test','hello redis'); echo $redis->get('test'); ?>
Output hello redis Success!