The following is shown in the way illustrated below:
Several articles on the installation and use of Redis, the following will explain how PHP to add redis extension!
The PHP manual does not provide Redis classes and methods, and does not provide the relevant extension module, but we can download the extension of PHP on Redis's website, there are more extensions, only to Phpredis for example.
1.phpredis Download
1. Click "Repository" to enter Redis's learning library, which has Redis extended code files and related introductions as well as classes and methods
2. Click "Releases" to enter Phpredis source file
3. Download the latest version of the Phpredis source files, select "tar.gz" Download
2.phpredis Configuration
1. Extract Phpredis files
Copy Code code as follows:
1 TAR-ZXVF phpredis-2.2.7.tar.gz
2. Installation Configuration Phpredis
1. Run the phpize5 command in the Phpredis directory to generate the Configure file
Phpize5
2. Installation Configuration Igbinary
Copy Code code as follows:
wget http://pecl.php.net/get/igbinary-1.2.1.tgz
./configure
Make
sudo make install
3. Installation Configuration Phpredis
Copy Code code as follows:
./configure--enable-redis-igbinary
Make
sudo make install
4. Modify PHP.ini, add (to order, add igbinary.so First, then add redis.so)
Copy Code code as follows:
Extension=igbinary.so
Extension=redis.so
3 View Phpredis
1. Use Phpinfo () to view
4.php Connection Redis Database
1. Open database service
2. Create a new redis.php file and type the following code to connect
Instantiate
$redis = new Redis ();
Connection Database
$redis->connect (' 127.0.0.1 ', 6379);
Authorization, password for you to set the authorization password, if not set, can not use the method
$redis->auth (password);
Keys method, query all key
$keys = $redis->keys ("*");
Var_dump ($keys);
3. Open the file in the browser to view the results of the query
The above is the entire content of this article I hope you like.