Php-redis Installing test Notes
This article mainly introduces the Php-redis installation test notes, this article explains the Redis installation, Redis test, installation Phpredis extension, test Php-redis and other content, the need for friends can refer to the following
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:
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 under 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 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:
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. 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:
The code is 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
The code is as follows:
Phpize
./configure--enable-redis-igbinary
Make && make install
A description of the error may appear as follows:
The code is 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.
The code is 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.
The code is 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:
The code is 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:
The code is as follows:
$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/963992.html www.bkjia.com true http://www.bkjia.com/PHPjc/963992.html techarticle Php-redis Installation Test notes This article mainly introduces the Php-redis installation test notes, this article explains the Redis installation, Redis test, installation Phpredis extension, test Php-redis and other content, need ...