tutorial on installing and configuring the Redis database under the Cenos system _redis

Source: Internet
Author: User
Tags php redis redis install redis redis server

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

Daemonize Yes

(2) Close the connection when the client is idle for a long time, or 0 if specified, to turn off the feature

Timeout 300

(3) Specify Redis log

Logfile/var/log/redis.log

(4) Specify local database storage directory

dir/data/redis/redis_db

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

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.