Installing Redis in a Linux environment

Source: Internet
Author: User
Tags fpm zts

Principle: PHP Default extension library does not contain Redis extensions; To support Redis extensions, you need to have redis.so this extension file

So our goal is to generate the redis.so extension file and modify the php.ini to support the Redis extension.

Prepare the test environment and software:

VM Virtual machine;

CentOS5.5 (has set up a good LNMP environment);

Redis-2.6.14 (Installation method, see my previous blog post);

phpredis.tar.gz (no online download);

My host computer is win10.

1. Upload the phpredis.tar.gz to Linux and unzip the

2. Enter Phpredis source Directory command: # CD Phpredis

(Here we need to know the PHP installation directory, I am here:/usr/local/php/bin)

3. Execute the command in the Phpredis source directory:/usr/local/php/bin/phpize:

Description: This phpize file in the/php/bin directory is the interface that PHP reserved when we need to install third-party extension libraries in the future

4. Perform the compilation

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

5. Installation

Make && make install

6. After the installation is complete, the last few pieces of code will tell us where the redis.so extension file is stored:

Put in:/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/this directory

This directory is a bit deep, it's okay, let's go to this directory and see what's Inside:

7. Enter the/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/directory to view

There's just one redis.so file in it, and that's the redis.so file we're going to generate. The next step is to modify php.ini.

8. Configure php.ini; let PHP support Redis extensions

Open php.ini to add this code anywhere inside:

extension= "Redis.so"

Save exit, restart PHP

Related commands:

Close Php:killall php-fpm

Start PHP:/USR/LOCAL/PHP/SBIN/PHP-FPM

Restart Nginx:service nginx Restart

9. Visit phpinfo.php and see that you have a redis extension

10. Next Test our PHP to see if we can properly operate Redis

Create phpredis.php under the Nginx Web root HTML to test the PHP connection to Redis;

# VI phpredis.php

Save exit to access this file with your browser:

Connection Successful!! Done

Redis can now be operated with PHP!

Share a Phpredis's Chinese handbook here: http://www.cnblogs.com/ikodota/archive/2012/03/05/php_redis_cn.html

The methods for working with Redis in PHP are all inside.

Installing Redis in a Linux environment

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.