How to install redis PHP extension package

Source: Internet
Author: User
Tags install redis

Try redisInstallation, PHPEnvironment connection and Testing

RedisIntroduction

RedisEssentiallyKey/valueDatabase, andMemcachedSimilarNosqlType database, but its data can be stored on the disk persistently. This solves the problem of no data loss after the service is restarted. Its value can beString(String ),List(List ),Sets(SET) orOrderedSets(Sorted set), all data types havePush/pop,Add/RemoveThe Union, intersection, and twoSetsThese operations are atomic,RedisDifferent sorting capabilities are also supported.

Apsaradb hybriddb for redis 2.0It also adds many new features, such as improved performance, new data types, and less memory utilization (AofAndVM)

RedisSupports most mainstream development languages, such:C,Java,C#,PHP,Perl,Python,Lua,Erlang,RubyAnd so on.

Official Website:Http://code.google.com/p/redis/

 

Installation Process

Latest stable version,Redis 2.0.4 stable

Wget

Http://redis.googlecode.com/files/redis-2.0.4.tar.gz

Tar zxf redis-2.0.4.tar.gz

CD redis-2.0.4

Unlike other softwareConfigure.

Make

Installed.

 

Create a directory

Mkdir/usr/local/redis2

CP redis-server redis-benchmark redis-cli redis. conf/Usr/local/redis2

 

Start:

./Redis-Server>/dev/null &

 

Test:

Storage value:

./Redis-cli set HX Value

Valid value:

./Redis-cli get HX

 

InstallPhpredisModule

 

Https://github.com/owlient/phpredis

 

DownloadPhpredis

Extract

Shell> Cd phpredis

Shell>/usr/local/PHP/bin/phpizeThisPhpizeYesPHPModule

Shell>./configure
-With-PHP-Config =/usr/local/PHP/bin/PHP-config

Shell> make

Shell> make install

NextPHP. iniAddExtension = redis. So
First, check whetherExtension_dir =/......
.

RestartApacheOrNginx

 

PHPCodeTest

$ Redis = new redis ();

$ Redis-> connect ('127.0.0.1′, 6379 );

$ Redis-> set ('test', 'Hello world! ');

Echo $ redis-> get ('test ');

?>

OutputHello world!

Http://code.google.com/p/php-redis/

 

RedisMaster/Slave Configuration

RedisMaster/Slave configuration is quite simple,SomeArticleRarryo wrote a large article, but there are actually two sentences.:

EnableRedis. conf

 Port 6381 (Note: it cannot be the same as the host)

 Sleverof
10.0.0.149 6383 (
Note:IPHostIP,6383HostRedisPort Number)

Restart the host first, and then restart the slave

Run./Redis-server redis. conf

If:


 

The configuration is successful.

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.