Centos 7-Installing the PHP redis extension

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.