I said before, how to install the Redis extension, but that can only use the Redis client to set and get cache, if you want to use PHP to operate the Redis cache, you must install the Phpredis extension.
There are many online installation Phpredis tutorials, but after the landlord of the test, a lot of tutorials can not be installed, it may be my operation error, here I recorded my installation of Redis amount process, share to everyone, but also as a record it. First of all, declare that the landlord is using CentOS 7.
1. Installing Phpize
# yum Install Php-devel
2. Download the Phpredis Package
# wget https://
Here again, you use this command in that directory, and the package is downloaded there.
3. Unzip with unzip
If you do not have this command, install it first, the command is: Yum install unzip
1 # unzip Master.zip
When the decompression is complete, a Phpredis-master folder is obtained.
4. Compiling PHP extensions
First, we have to go into the Phpredis-master folder first.
Then compile with the following command
1 # Phpize
5. Configuring the Environment
Use the following command or a directory in 4
1 #./configure
6. Compiling
When the compilation is complete, it displays:
Build compatedonn' t forget to run ' make test '. /usr/lib/php/modules
Landlord's machine is 32-bit, so here is the LIB, if it is 64-bit machine, then the display is lib64, specifically you can go to the/usr directory to see
Go to the/usr/lib/php/modules/folder and we'll find the redis.so extension
7. Modify/etc/php.ini
To add an extension:
Landlord's configuration file has a comment: extension=mysql.so, I directly uncomment, change the content, specifically see your operation.
8. Restart the Apache service
Remember to restart the service
# systemctl Restart httpd
9. Simple Code Demo
Landlord wrote a simple code in Linux to test the effect
1 <? PHP 2 $redis New Redis (); 3 $redis. Set (' PBY ', 1234);
Use PHP file name. php to compile the files, and finally get PBY in the Redis client to get the correct results.
Centos 7-Installing the PHP redis extension