Php-redis Installing test notes, Php-redis test notes _php Tutorials

Source: Internet
Author: User
Tags redis server

Php-redis Installing test notes, Php-redis test notes


Back-end development used to PHP operation Redis, in this will install the test process encountered during the summary record, for future reference! (System for Ubuntu)

1.redis Installation

Download Address: http://download.redis.io/releases/
Unzip the installation:
Copy the Code code as follows:
TAR-XVF redis-2.8.17.tar.gz
Make
sudo make install

For ease of use, create a Redis directory under the/usr directory and copy the following files to the/usr/redis/directory:
Copy the Code code as follows:
/yourdir/redis-2.8.17/redis.conf
/yourdir/redis-2.8.17/src/redis-benchmark
/yourdir/redis-2.8.17/src/redis-server
/yourdir/redis-2.8.17/src/redis-cli

Of course, you can also use the soft connection to achieve the purpose of convenience. In addition, you can also add redis-server to boot, here withheld.

2.redis Test

1) First Open Redis server program
For the convenience of testing, we will redis.conf the values of loglevel and logfile in the configuration file as follows:
LogLevel Debug
LogFile "/tmp/redis.log"
jay13@ubuntu:/usr/redis$ Redis-server redis.conf
2) Turn on the Redi client and make the operation of the Redis database by adding and checking the client. The logs generated during the entire operation can be viewed in/tmp/redis.log.
Take the simplest key operation as an example, with the following example:

Copy the Code code as follows:
jay13@ubuntu:/usr/redis$ REDIS-CLI
127.0.0.1:6379> Set JAY13 jb51.net
Ok
127.0.0.1:6379> set Jay Hello,world
Ok
127.0.0.1:6379> get Jay
"Hello,world"
127.0.0.1:6379> Get JAY13
"Jb51.net"
127.0.0.1:6379> del Jay
(integer) 1
127.0.0.1:6379> get Jay
(nil)
127.0.0.1:6379> Set JAY13 www.jb51.net
Ok
127.0.0.1:6379> Get JAY13
"Www.jb51.net"

3. Installing the Phpredis Extension

When installing PHP using sudo apt-get install PHP5, the default is no phpize installed, we need phpize to install Phpredis, so we need to install Phpize first.
1) We get phpize by installing PHP developer tools. Execute the following command:
Copy the Code code as follows:
sudo apt-get install Php5-dev

2) Get Phpredis source file
Latest Phpredis Address: Https://github.com/nicolasff/phpredis
Follow the instructions on GitHub to install the following

Copy the Code code as follows:
Phpize
./configure--enable-redis-igbinary
Make && make install

A description of the error may appear as follows:
Copy the Code code as follows:
Checking for Igbinary includes ... configure:error:Cannot find Igbinary.h

This is because we do not have a igbinary extension, which is something that Phpredis relies on.
Well, how do you install Igbinary?

Using apt-get does not fail to install, we install by downloading the installation file.

Copy the Code code as follows:
wget http://pecl.php.net/get/igbinary-1.1.1.tgz

TAR-XZVF igbinary-1.1.1.tgz

CD igbinary-1.1.1

Phpize

./configure # No need for extra config params

Make

Make install

After installing the Igbinary, you can install Phpredis with the following command.
Copy the Code code as follows:
Phpize

./configure–enable-redis-igbinary

Make && make install

At this point, the installation is complete.

We modified the php.ini configuration file to add the two extensions just installed to the php.ini file, adding the following statements:
Copy the Code code as follows:
Extension=igbinary.so

Extension=redis.so

Restart apache,done!!!

4. Test Php-redis

In the Web root/var/www/, create a new file test.php with the following contents:

Copy the Code code as follows:
<?php
$redis = new Redis ();
$redis->connect (' 127.0.0.1 ', 6379);
$redis->set (' Jay13 ', ' www.jb51.net ');
Echo ' JAY13: '. $redis->get (' Jay13 ');
Echo '
';
Echo ' Jay12: '. $redis->get (' Jay12 ');
?>

Results such as:

http://www.bkjia.com/PHPjc/963842.html www.bkjia.com true http://www.bkjia.com/PHPjc/963842.html techarticle Php-redis Install test notes, Php-redis test notes back-end development used to PHP operation Redis, here will install the test process encountered in the summary record, for future reference! (System ...

  • 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.