How to compile redis and phpredis in Linux _ PHP-php Tutorial

Source: Internet
Author: User
This article mainly introduces how to compile redis and phpredis in Linux, analyzes the download, compilation, installation, and problems encountered in redis and the corresponding solutions, for more information about how to compile redis and phpredis in Linux, see this document. We will share this with you for your reference. The details are as follows:

1. preparations

Download Software: this site.
Operating system: CentOS 5.5
Redis edition: 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 the following error occurs:

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

Solution:

make CFLAGS="-march=i686" 

When "Hint: To run 'Make test' is a good idea;)" is displayed, the compilation is successful.

Make install // install

Note: make install is actually:

cp -p redis-server /usr/local/bincp -p redis-benchmark /usr/local/bincp -p redis-cli /usr/local/bincp -p redis-check-dump /usr/local/bincp -p redis-check-aof /usr/local/bin

In this way, redis is successfully installed.

The next step is to start Redis. the executable files generated after the above compilation are copied to the/usr/local/bin directory. Their functions are as follows:

Redis-server: daemon startup program of the Redis server
Redis-cli: Redis command line operation tool. Of course, you can also use telnet to operate based on its plain text protocol.
Redis-benchmark: Redis performance testing tool to test the read/write performance of Redis in your system and your configuration

To start the Redis process, you only need to execute this/usr/local/bin/redis-server/path-to/redis. conf

Keep up with the redis configuration file after startup, so that Redis can be started smoothly.

3. problems with starting redis

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

Solution: modify the configuration file redis. conf and set maxmemory to maxmemory 1024000000 # allocate MB of memory.

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. overcommit_memory = 1' for this to take effect.

Solution: Warning: the excessive memory usage is set to 0! In a low-memory environment, the backend storage may fail. To fix this problem, go to/etc/sysctl. add 'vm. conf. overcommit_memory = 1', and then restart (or run the command 'sysctl vm. overcommit_memory = 1.

If no information is displayed during startup, the startup is successful. You can also use "netstat-tnl" to check whether Port 6379 is enabled.

4. enable and disable redis

Redis-server/usr/local/redis-2.6.9/redis. conf enabled, note: you need to specify the redis configuration file

Pkill redis-server stop redis
Redis-cli shutdown stop redis

5. redis. conf parameter information

For details about redis and its parameters, refer to Redis basic knowledge, installation, deployment, and configuration notes on this site.

6. compile phpredis

unzip phpredis-master.zipcd phpredis-master/usr/local/php/bin/phpize./configure –with-php-config=/usr/local/php/bin/php-configmake && make install

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

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.