Install Redis under the PHP environment in CentOS

Source: Internet
Author: User

I. Installation of Redis (only available on the server and not yet accessible through the browser)

(1) First download Redis:wget http://download.redis.io/releases/redis-4.0.9.tar.gz

(2) Decompression REDIS:TAR-ZXVF redis-4.0.9.tar.gz

(3) Go to Redis directory: CD redis-4.0.9

(4) Make compile: Make

(5) Enter the SRC directory of Redis to execute: CD src

(6) Perform open redis:./redis-server

If you see the unique official Redis logo, the installation is successful, or it can be executed./REDIS-CLI Open Redis Client, perform simple set operation, if can get the description of installation success

Second, installation Phpredis (can be accessed via the browser at this time)

(1) Download Phpredis installation package: wget Https://github.com/phpredis/phpredis/archive/develop.zip

(2) Decompression Phpredis:unzip Develop.zip

(3) Enter Phpredis directory: CD CD phpredis-develop/

(4) Generate Configure files using Phpize:/usr/local/php7-legend/bin/phpize

(5) Then check that the current environment meets the dependencies to install the software:./configure--with-php-config=/usr/local/php7-legend/bin/php-config

(5) Then compile: make-j

(6) Then install: Make install

(7) Then go to php Custom extension directory:/usr/local/php7-legend/lib/php/extensions/no-debug-non-zts-20160303/

(8) Normal should be able to see: redis.so

(9) Then add the Redis extension to the configuration file configuration: cd/usr/local/php7-legend/lib/

(10) Added: extension=redis.so

(11) Remember to restart PHP-FPM, and then see if the phpinfo information has a redis extension

This is the time to execute the following code test (Redis server must be turned on)
$redis = new Redis (), $redis->connect (' 127.0.0.1 ', 6379), $redis->set ("Who", "Me"), $test = $redis->get ("who"); Var_dump ($test);

  

Install Redis under the PHP environment in CentOS

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.