Graphics and Text introduction PHP add Redis module and connection _php skills

Source: Internet
Author: User

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.

Related Article

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.