Phpredis installation, configuration and simple use

Source: Internet
Author: User
Tags configuration php zts install redis

Before installing Phpredis, install Redisbefore installing the Phpredis plugin.

1. Download and install

On the Linux server, the command line executes the following command (CD./usr LOCAL/SRC General source code is here (recommended source installation))

wget https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gztar zxvf phpredis-2.2. 4 . TAR.GZCD Phpredis-2.2. 4/usr/local/php5.5.30/bin/phpize
./configure--with-php-config=/usr/local/php5.5.30/bin/php-config
Make make Install

Description

wget: Download the remote file to the local current folder.

Tar xzf: Unzip the file to the current folder directory

  CD: Go to Folder

/usr/local/php/php5.5.30/phpize generating Configure configuration files with Phpize

./configure--with-php-config=/usr/local/php5.5.30/bin/php-config Configure PHP so that it can use Redis

Make make install: Install Redis

  Error message:

If you generate configure configuration file with Phpize error:cannot find autoconf. The configuration PHP will be error:./configure no file or directory

Workaround:

Execute the following command

wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gztar-zvxf m4-1.4. 9 . TAR.GZCD M4-1.4. 9/. /configure && make && make installcd. /wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gztar-zvxf autoconf-  2.62. TAR.GZCD autoconf-2.62/. /configure && make && make install

Install successfully, you can see the following folder (remember this folder name may not be the same, but the same format no-debug-zts-20121212)

/usr/local/php5.5.30/lib/php/extensions/no-debug-zts-20121212/

2, Configuration Phpredis
Open PHP config file/usr/local/php/etc/php.ini add code ( reminder to see how much you no-debug-zts-20121212, don't copy ):

  

" /usr/local/php5.5.30/lib/php/extensions/no-debug-zts-20121212 " extension=redis.so

Then restart Apache:

/usr/local/apache/bin/apachectl restart

The execution of Phpinfo () now shows that the Phpredis installation was successful.

  

3, simple test using Phpredis plug-in operation Redis

  

<? PHP    New Redis (); $redis->connect ('127.0.0.1'6379); $redis Set ('foo','bar'); Echo $redis Get ('foo');

The output is: Bar

Description Success O (∩_∩) o haha ~

  

  

  

Phpredis installation, configuration and simple use

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.