Install the redis service and phpredis extension in linux

Source: Internet
Author: User
Redis installation Download, extractandcompileRediswith: drawing $ cdredis-3.0.4 $ makeThebinariesthataren... A: redis installation
Download, extract and compile Redis:

$ Wget http://download.redis.io/releases/redis-3.0.4.tar.gz

$ Tar xzf redis-3.0.4.tar.gz

$ Redis-3.0.4 cd

$ Make

The binaries that are now compiled are available in the src directory. Run Redis:

$ Src/redis-server

You can interact with Redis using the built-in client:

$ Src/redis-cli

Redis> set foo bar
OK
Redis> get foo
"Bar"

More: http://www.redis.io/download

II. php extension:
More versions: http://pecl.php.net/package/redis

Wget http://pecl.php.net/get/redis-2.2.5.tgz

# Decompress

Tar zxvf redis-2.2.5.tgz

# Enter the installation directory

Cd redis-2.2.5

/Usr/local/php/bin/phpize

# Configuration

./Configure -- with-php-config =/usr/local/php/bin/php-config

# Compile and install

Make & make install

After the installation is complete, the following installation path appears:
/Usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/

Configure php support
# Edit the configuration file and add the following content in the last line

Vim/usr/local/php/etc/php. ini

Extension = "redis. so"

At this time, phpinfo () can see the redis extension.

Small example of redis:

$ Redis = new redis ();

$ Test = $ redis-> connect ('2017. 0.0.1 ', 127 );

Var_dump ($ test );

$ Result = $ redis-> set ('test', "webyang.net ");

Var_dump ($ result); // result: bool (true)

$ Result = $ redis-> get ('test ');

Var_dump ($ result); // result: string (11) "webyang.net"

The reason for this is that the company uses Alibaba's RDS and occasionally gets stuck when concurrency is high. The CPU is directly 6000. RDS is 12 GB of memory, with a maximum IOPS of 2000 and a maximum connection count, in fact, we are far from reaching this number, so we want to create a redis queue for fun and put some things that do not need to be executed in real time in the queue for execution. I wanted to directly execute the queue after the data is saved for several minutes. I didn't think of a good method. I had to write a script in linux and run it once every few minutes, this is not very intelligent. there are some waste of resources. do you have any good ideas? Storm of mind ~

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.