Home  >  Article  >  Backend Development  >  Php-Redis installation test notes_PHP tutorial

Php-Redis installation test notes_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:04:57910browse

Php-Redis installation test notes

This article mainly introduces Php-Redis installation test notes. This article explains redis installation, redis testing, installing phpredis extension, and testing php- For redis and other content, friends who need it can refer to it

Back-end development uses PHP to operate redis. Here, we will summarize and record the problems encountered during the installation and testing process for future reference! (The system is ubuntu)

1.redis installation

Download address: http://download.redis.io/releases/
Unzip and install:

The code is as follows:


tar -xvf redis-2.8.17.tar.gz
make
sudo make install
For ease of use, create a redis directory in the /usr directory and copy the following files to the /usr/redis/ directory:

The code is 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 soft connections to achieve the purpose of convenient use. In addition, you can also add redis-server to startup, which is omitted here.

2.redis test

1) First open the redis server program
To facilitate testing, we modified the values ​​of loglevel and logfile in the redis.conf configuration file as follows:
loglevel debug
logfile “/tmp/redis.log”
jay13@ubuntu:/usr/redis$ redis-server redis.conf
2) Open the redi client and perform addition, deletion, modification and query operations in the redis database through the client. The logs generated during the entire operation can be viewed in /tmp/redis.log.
Taking the simplest key operation as an example, the example is as follows:

The code is 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. Install phpredis extension

When using sudo apt-get install php5 to install php, phpize is not installed by default. When we install phpredis, we need to use phpize, so we need to install phpize first.
1) We get phpize by installing php developer tools. Just execute the following command:

The code is as follows:


sudo apt-get install php5-dev
2) Get the phpredis source file
The latest phpRedis address: https://github.com/nicolasff/phpredis
When installing as follows following the instructions on GitHub,

The code is as follows:


phpize
./configure --enable-redis-igbinary
make && make install

The following error description may appear:

The code is as follows:


checking for igbinary includes... configure: error: Cannot find igbinary.h
This is because we do not have the igbinary extension, which is something that phpredis depends on.
Okay, how to install igbinary?

The installation cannot be completed using apt-get. We install it by downloading the installation file.

The code is as follows: