One: Install Redis
wget http://redis.googlecode.com/files/redis-2.6.14.tar.gz
tar zxvf redis-2.6.14.tar.gz
CD redis-2.6.14 Make
Prefix=/usr/local/redis Install
Two: Configure Redis
Use the default profile and make a little change.
1. Customary practice, the configuration file in the source code installed folder, easy to manage it
mkdir/usr/local/redis/etc/
CP redis-2.6.14/redis.conf/usr/local/redis/etc/
2. Modify configuration file/usr/local/redis/etc/redis.conf
(1) Redis is not run as a daemon by default and can be modified using Yes to enable the daemon
(2) Close the connection when the client is idle for a long time, or 0 if specified, to turn off the feature
(3) Specify Redis log
Logfile/var/log/redis.log
(4) Specify local database storage directory
3. Start Redis
/usr/local/redis/bin/redis-server/usr/local/redis/etc/redis.conf
Three: Test Redis
1 demonstrates a simple set Key,get key operation ...
Please install the PHP redis client first, the specific installation reference (Https://github.com/nicolasff/phpredis)
<?php
$redis = new Redis ();
try{
$redis->connect (' 127.0.0.1 ', 6379);
}
catch (Exception $e) {
die ("Cannot connect to Redis server:". $e->getmessage ());
}
$redis->set (' name ', ' Budong ');
echo $redis->get (' name ');
? >
Output Budong, the installation is successful.
2 Redis can play too much, Operation dimension must view Redis run information, as follows:
[Root@cache ~]#/usr/local/redis/bin/redis-cli
redis 127.0.0.1:6379> INFO
Some of the results are as follows:
redis_version:2.4.7
redis_git_sha1:00000000
redis_git_dirty:0
arch_bits:64
multiplexing_api: Epoll
gcc_version:4.1.2
process_id:26615
uptime_in_seconds:2717407
uptime_in_days:31
lru_ clock:117839
used_cpu_sys:102659.58
used_cpu_user:101565.17
used_cpu_sys_children:125215.15
used_cpu_user_children:807371.44