Linux下編譯redis和phpredis的方法
本文講述了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)看見(jiàn)“Hint: To run 'make test' is a good idea ;)” 說(shuō)明編譯成功。
make install //安裝
說(shuō)明:其實(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 就安裝成功了。
接下來(lái)就是啟動(dòng)Redis了, 上面編譯后生成的那些可執(zhí)行文件拷貝到了/usr/local/bin目錄下面, 他們的作用分別是:
redis-server:Redis服務(wù)器的daemon啟動(dòng)程序
redis-cli:Redis命令行操作工具。當(dāng)然,你也可以用 telnet 根據(jù)其純文本協(xié)議來(lái)操作
redis-benchmark:Redis性能測(cè)試工具,測(cè)試Redis在你的系統(tǒng)及你的配置下的讀寫(xiě)性能
啟動(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)的問(wè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.
解決方法:警告:過(guò)量使用內(nèi)存設(shè)置為0!在低內(nèi)存環(huán)境下,后臺(tái)保存可能失敗。為了修正這個(gè)問(wèn)題,請(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í)候沒(méi)有任何信息,表明啟動(dòng)成功。也可以使用 "netstat -tnl" 查看6379端口是否啟動(dòng)。
4、開(kāi)啟和關(guān)閉 redis
redis-server /usr/local/redis-2.6.9/redis.conf 開(kāi)啟,注:需要指定 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ǔ)法入門(mén)教程》、《php操作office文檔技巧總結(jié)(包括word,excel,access,ppt)》、《php日期與時(shí)間用法總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門(mén)教程》、《php字符串(string)用法總結(jié)》、《php+mysql數(shù)據(jù)庫(kù)操作入門(mén)教程》及《php常見(jiàn)數(shù)據(jù)庫(kù)操作技巧匯總》
希望本文所述對(duì)大家PHP程序設(shè)計(jì)有所幫助。
相關(guān)文章
php5.2以下版本無(wú)json_decode函數(shù)的解決方法
這篇文章主要介紹了php5.2以下版本無(wú)json_decode函數(shù)的解決方法,需要的朋友可以參考下2014-05-05
PHP學(xué)習(xí)筆記 IIS7下安裝配置php環(huán)境
PHP學(xué)習(xí)筆記 IIS7下安裝配置php環(huán)境,需要的朋友可以參考下2012-10-10
解析PHP中DIRECTORY_SEPARATOR,PATH_SEPARATOR兩個(gè)常量的作用
本篇文章是對(duì)PHP中DIRECTORY_SEPARATOR,PATH_SEPARATOR兩個(gè)常量的作用進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06
修改了一個(gè)很不錯(cuò)的php驗(yàn)證碼(支持中文)
很早前在PHP喜悅國(guó)際村看到的一個(gè)驗(yàn)證碼類,寫(xiě)的很強(qiáng)。但有些邏輯方面感覺(jué)處理的不好,然后我不喜歡完全用session來(lái)處理驗(yàn)證碼。這在大型系統(tǒng)中是很不好的2007-02-02
PHP簡(jiǎn)單檢測(cè)網(wǎng)址是否能夠正常打開(kāi)的方法
這篇文章主要介紹了PHP簡(jiǎn)單檢測(cè)網(wǎng)址是否能夠正常打開(kāi)的方法,涉及php中curl的簡(jiǎn)單使用技巧,需要的朋友可以參考下2016-09-09

