Installing Redis and PHP Redis extensions under Linux

Source: Internet
Author: User
Tags benchmark download redis php redis redis server
      1. Installing Redis and PHP Redis extensions under Linux

      2. Environment configuration: centos6.0 nginx/1.0.0 php/5.3.8 mysql/5.5.17

      3. Step one, download Redis

      4. can go to http://redis.io/to download the latest version

      5. I'm using a Redis 2.8.11.

      6. Go to the Software installation package storage directory: cd/var/install/software/

      7. wget http://download.redis.io/redis-stable.tar.gz

  1. Step two, compile the source program

  2. Tar xvzf redis-stable.tar.gz

  3. CD redis-stable

  4. Make

  5. Make install

  6. If make has an exception:

  7. 1) make[2]: Cc:command not found

  8. Exception reason: GCC is not installed

  9. Solution: Yum Install gcc-c++

  10. 2) zmalloc.h:51:31:error:jemalloc/jemalloc.h:no such file or directory

  11. Exception reason: Some compiler dependencies or original compilation legacy problems

  12. Solution: Make Distclean. Clean it up and make it again.

  13. After make is successful, make test is required to have an exception in make test

  14. 1) couldn ' t execute "tclsh8.5": No such file or directory

  15. Exception reason: Tcl not installed

  16. Solution: Yum install-y tcl.

  17. When the make command is completed, 5 executables are generated in the SRC directory, namely Redis-server, REDIS-CLI, Redis-benchmark, redis-check-aof, Redis-check-dump, Their role is as follows:

  18. Redis-server:redis Server Daemon Startup program

  19. Redis-cli:redis command-line operation tool. Of course, you can also use Telnet to operate on its plain text protocol.

  20. Redis-benchmark:redis Performance testing tools to test the read and write performance of Redis in your system and in your configuration

  21. Redis-check-aof: Update log check

  22. Redis-check-dump: for local database checking

  23. Step three, configure

  24. CP redis-server/usr/local/bin/

  25. CP redis-cli/usr/local/bin/

  26. Then create a new directory, store the configuration file

  27. Mkdir/etc/redis

  28. Mkdir/var/redis

  29. Mkdir/var/redis/log

  30. Mkdir/var/redis/run

  31. mkdir/var/redis/6379

  32. Locate the profile template in the Redis solution directory and copy it to the following location.

  33. CP redis.conf/etc/redis/6379.conf modified with vim command

  34. Daemonize Yes

  35. Pidfile/var/redis/run/redis_6379.pid

  36. Logfile/var/redis/log/redis_6379.log

  37. dir/var/redis/6379

  38. Finally, run Redis:

  39. $ redis-server/etc/redis/6379.conf

  40. Available NETSTAT–ATLN View port is a successful boot installation

  41. Step four, Operation Redis database

  42. #./redis-cli

  43. "http://img.blog.csdn.net/20140617150954812?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaV9icnVjZQ==/font/ 5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/dissolve/70/gravity/southeast "alt=" "/>

  44. Let's take a brief look at the database. In case the instance is turned on:

  45. 1. Inserting data

  46. Redis 127.0.0.1:6379> Set name WWL

  47. Ok

  48. Set a Key-value pair.

  49. 2. Query data

  50. Redis 127.0.0.1:6379> Get Name

  51. "WWL"

  52. Remove the value corresponding to the key.

  53. 3. Delete key values

  54. Redis 127.0.0.1:6379> del name

  55. Delete this key and the corresponding value.

  56. 4. Verify that the key is present

  57. Redis 127.0.0.1:6379> exists name

  58. (integer) 0

  59. 0, which means that the key does not exist; 1 stands for existence.

  60. Step five, download the Phpredis extension

  61. Download Https://github.com/nicolasff/phpredis/downloads first.

  62. #wget https://github.com/nicolasff/phpredis/downloads

  63. # TAR-ZXVF Nicolasff-phpredis-2.1.3-124-gd4ad907.tar.gz

  64. # MV nicolasff-phpredis-d4ad907 php-5.3.8/ext/phpredis/

  65. # CD php-5.3.8/ext/phpredis/

  66. #/usr/local/php/bin/phpize

  67. #./configure--with-php-config=/usr/local/php/bin/php-config

  68. # Make && make install

  69. Configure PHP.ini

  70. Vi/usr/local/php/lib/php.ini

  71. Join

  72. Extension=redis.so

  73. )

  74. First to see if there is extension_dir=/....

  75. Restart Apache or nginx (reload PHP--->/etc/init.d/php-fpm restart)

  76. To the normal situation, you can see the Redis extension with Phpinfo

  77. If Phpinfo does not have Redis extension information, add/etc/php.d/redis.ini (path is my local)

  78. Redis.ini content is as follows:

  79. ; Enable MySQL Extension module

  80. Extension=redis.so

  81. Restart Apache or nginx (reload PHP--->/etc/init.d/php-fpm restart)

  • 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.