欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Linux下編譯redis和phpredis的方法

 更新時(shí)間:2016年04月07日 10:00:14   作者:ruxingli  
這篇文章主要介紹了Linux下編譯redis和phpredis的方法,分析了redis的下載,編譯,安裝及遇到的問題與相應(yīng)的解決方法,需要的朋友可以參考下

本文講述了Linux下編譯redis和phpredis的方法。分享給大家供大家參考,具體如下:

1、準(zhǔn)備工作

下載軟件:本站下載地址。
操作系統(tǒng):CentOS 5.5
redis 版本:redis-2.6.9

2、編譯安裝

tar zxvf redis-2.6.9.tar.gz //解壓 
cd redis-2.6.9 
make  //編譯 

如果出現(xiàn)如下錯(cuò)誤:

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

解決方法:

make CFLAGS="-march=i686" 

當(dāng)看見“Hint: To run 'make test' is a good idea ;)” 說明編譯成功。

make install  //安裝 

說明:其實(shí) make install 就是:

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

這樣,redis 就安裝成功了。

接下來就是啟動(dòng)Redis了, 上面編譯后生成的那些可執(zhí)行文件拷貝到了/usr/local/bin目錄下面, 他們的作用分別是:

redis-server:Redis服務(wù)器的daemon啟動(dòng)程序
redis-cli:Redis命令行操作工具。當(dāng)然,你也可以用 telnet 根據(jù)其純文本協(xié)議來操作
redis-benchmark:Redis性能測(cè)試工具,測(cè)試Redis在你的系統(tǒng)及你的配置下的讀寫性能

啟動(dòng) Redis 進(jìn)程只需要執(zhí)行這個(gè) /usr/local/bin/redis-server /path-to/redis.conf

啟動(dòng)的時(shí)候后面要跟上 redis 的配置文件, 這樣Redis就順利啟動(dòng)了.

3、啟動(dòng) redis 會(huì)出現(xiàn)的問題

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

解決方法:修改配置文件 redis.conf  將 maxmemory 設(shè)置為 maxmemory 1024000000 #分配256M內(nèi)存

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.

解決方法:警告:過量使用內(nèi)存設(shè)置為0!在低內(nèi)存環(huán)境下,后臺(tái)保存可能失敗。為了修正這個(gè)問題,請(qǐng)?jiān)?etc/sysctl.conf 添加一項(xiàng) 'vm.overcommit_memory = 1' ,然后重啟(或者運(yùn)行命令'sysctl vm.overcommit_memory=1' )使其生效。

當(dāng)啟動(dòng)的時(shí)候沒有任何信息,表明啟動(dòng)成功。也可以使用 "netstat -tnl" 查看6379端口是否啟動(dòng)。

4、開啟和關(guān)閉 redis

redis-server /usr/local/redis-2.6.9/redis.conf 開啟,注:需要指定 redis 的配置文件

pkill redis-server 停止 redis
redis-cli shutdown 停止 redis

5、redis.conf 的參數(shù)信息

關(guān)于redis及其參數(shù)信息可參考本站《Redis基本知識(shí)、安裝、部署、配置筆記

6、編譯 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

修改 php.ini 文件。加載 redis.so 模塊,重啟 Apache !

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php curl用法總結(jié)》、《PHP運(yùn)算與運(yùn)算符用法總結(jié)》、《PHP網(wǎng)絡(luò)編程技巧總結(jié)》、《PHP基本語(yǔ)法入門教程》、《php操作office文檔技巧總結(jié)(包括word,excel,access,ppt)》、《php日期與時(shí)間用法總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫(kù)操作入門教程》及《php常見數(shù)據(jù)庫(kù)操作技巧匯總

希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論