How to compile Redis and Phpredis under Linux _php tips

Source: Internet
Author: User
Tags benchmark redis version redis server

This article describes the method of compiling Redis and Phpredis under Linux. Share to everyone for your reference, specific as follows:

1. Preparation work

Download software: This site download the address.
Operating system: CentOS 5.5
Redis version: redis-2.6.9

2. Compile and install

Tar zxvf redis-2.6.9.tar.gz//Unzip 
CD redis-2.6.9 
make  //compile 

If you receive the following error:

zmalloc.o:in function ' zmalloc_used_memory ':
/data/redis-2.6.9/src/zmalloc.c:223:undefined reference to ' __sync_add_and_fetch_4 '
Collect2:ld returned 1 exit status
MAKE[1]: * * * [redis-server] Error 1
MAKE[1]: Leaving directory '/DATA/REDIS-2.6.9/SRC '
Make: * * * [ALL] Error 2

Workaround:

Make cflags= "-march=i686" 

When you see "hint:to Run" make Test ' was a good idea;) ' Indicates that the compilation was successful.

Make install  

Description: Actually make install is:

Cp-p redis-server/usr/local/bin
cp-p redis-benchmark/usr/local/bin
cp-p redis-cli/usr/local/bin
R Edis-check-dump/usr/local/bin
cp-p Redis-check-aof/usr/local/bin

In this way, the Redis was installed successfully.

The next step is to start the Redis, and the compiled executable files are copied to the/usr/local/bin directory, and their roles are:

Daemon startup program for Redis-server:redis server
Redis-cli:redis Command line Operation tool. Of course, you can also use Telnet to operate on its plain text protocol.
Redis-benchmark:redis Performance Testing tool to test Redis performance in your system and your configuration

Starting the Redis process requires only the execution of this/usr/local/bin/redis-server/path-to/redis.conf

Start the time to keep up with the Redis configuration file, so that the Redis on the smooth start.

3, start the Redis will appear problems

Warning:32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with ' noeviction ' policy now.

Workaround: Modify the configuration file redis.conf set MaxMemory to MaxMemory 1024000000 #分配256M内存

WARNING Overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add ' vm.overcommit_memory = 1 ' to/etc/sysctl.conf and then reboot or run the command ' Sysctl vm.overcom Mit_memory=1 ' for this to take effect.

WORKAROUND: Warning: Excessive use of memory set to 0! In a low memory environment, background saves may fail. To fix this problem, add a ' vm.overcommit_memory = 1 ' in/etc/sysctl.conf and then reboot (or Run command ' sysctl Vm.overcommit_memory=1 ') to make it effective.

When booting, there is no information indicating that the startup was successful. You can also use "NETSTAT-TNL" to see if Port 6379 is started.

4. Open and Close Redis

Redis-server/usr/local/redis-2.6.9/redis.conf Open, Note: You need to specify a Redis configuration file

Pkill redis-server Stop Redis
REDIS-CLI shutdown Stop Redis

5, the redis.conf parameter information

About Redis and its parameter information can refer to this site "Redis basic knowledge, installation, deployment, configuration Notes"

6, compile Phpredis

Unzip Phpredis-master.zip
cd phpredis-master
/usr/local/php/bin/phpize
./configure–with-php-config=/ Usr/local/php/bin/php-config make
&& make install

Modify the php.ini file. Load redis.so module, restart Apache!

More interested in PHP related content readers can view the site topics: "Php Curl Usage Summary", "PHP operation and operator Usage Summary", "PHP Network Programming Skills Summary", "PHP Basic Grammar Introductory Tutorial", "PHP operation Office Document skills Summary (including Word, Excel,access,ppt), "The PHP date and time usage summary", "PHP object-oriented Programming Introduction Tutorial", "PHP string (String) Usage Summary", "Php+mysql Database operation Introduction Tutorial" and "PHP common database Operation skill Summary"

I hope this article will help you with the PHP program design.

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.