Install the redis service and phpredis extension in linux

Source: Internet
Author: User
Tags php redis
: This article describes how to install the redis service and phpredis extension in linux. For more information about PHP tutorials, see. More please support: http://www.webyang.net/Html/web/article_174.html

I. redis installation

Download, extract and compile Redis:
 
 
  1. $ wget http://download.redis.io/releases/redis-3.0.4.tar.gz
  2. $ tar xzf redis-3.0.4.tar.gz
  3. $ cd redis-3.0.4
  4. $ make
The binaries that are now compiled are available in the src directory. Run Redis:
 
 
  1. $ src/redis-server
You can interact with Redis using the built-in client:
 
 
  1. $ 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
 
 
  1. Wget http://pecl.php.net/get/redis-2.2.5.tgz
  2. # Decompress
  3. Tar zxvf redis-2.2.5.tgz
  4. # Enter the installation directory
  5. Cd redis-2.2.5
  6. /Usr/local/php/bin/phpize
  7. # Configuration
  8. ./Configure -- with-php-config =/usr/local/php/bin/php-config
  9. # Compile and install
  10. 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
 
 
  1. vim /usr/local/php/etc/php.ini
  2. extension="redis.so"
At this time, phpinfo () can see the redis extension.
Small example of redis:
 
 
  1. $ Redis = new redis ();
  2. $ Test = $ redis-> connect ('2017. 0.0.1 ', 127 );
  3. Var_dump ($ test );
  4. $ Result = $ redis-> set ('test', "webyang.net ");
  5. Var_dump ($ result); // result: bool (true)
  6. $ Result = $ redis-> get ('test ');
  7. 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, we are far from reaching this number, so we are considering a redisQueuePlay, put some things that do not need to be executed in real timeQueue. I wanted to directly execute the command after the data is saved for several minutes.QueueI did not expect a good method. I can only write a script in linux to run it once every few minutes. In fact, this is not very intelligent, and some resources are wasted, do you have any good ideas? Brainstorm ~

The above describes how to install the redis service and php redis extension in linux, including the queue content, and hope to be helpful to friends who are interested in the PHP Tutorial.

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.