小貝_redis安裝與部署

來源:互聯網
上載者:User

標籤:redis   nosql   

安裝Redis服務及php Redis拓展

一、Redis相關檔案下載
二、Redis安裝
三、phpredis拓展安裝

 

一、本文檔相關檔案下載

1、Redis: http://redis.io/download

2、php Redis拓展: http://pecl.php.net/package/redis

3、php: http://php.net/downloads.php

(備忘: 本文檔下載的是redis為redis-3.0.2.tar.gz而 php redis拓展為redis-2.2.7.tgz)

4、本測試機系統為 CentOS release 6.3 (Final)

   php環境為php-5.6.11

 

二、安裝redis服務

1、安裝Redis服務

       a、tar -zxf redis-3.0.2.tar.gz

       b、make && make install

2、安裝成功後,src會出現如下等可執行檔

(備忘:  mkreleasehdr.sh、redis-check-dump、redis-cli、redis-benchmark、redis-check-aof、redis-sentinel、redis-server、redis-trib.rb

其中: redis-server則是啟動redis服務的服務端

        redis-cli則是連結redis的用戶端

)

3、啟動服務及測試redis

       3.1、建立目錄bin和etc (bin存放redis可以執行檔案、etc則存放redis設定檔)

       [[email protected] src]# mv mkreleasehdr.shredis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinelredis-server  redis-trib.rb ../bin/

       [[email protected] redisd]# mv redis.conf etc/

       3.2、啟動redis

       [[email protected] redisd]# ./bin/redis-server./etc/redis.conf

       3.3、檢查redis是否啟動 (redis預設連接埠為6379)

       3.4、使用內建用戶端操作redis

      

3.5、設定redis自啟動

修改/etc/rc.local檔案

/usr/local/redisd/bin/redis-server  /usr/local/redisd/etc/redis.conf>/dev/null &

3.6、關閉redis

[[email protected] redisd]# ./bin/redis-clishutdown

 

4、常見異常及處理

異常一:make[2]: cc: Command not found

異常原因:沒有安裝gcc

解決方案:yum installgcc-c++

異常二:zmalloc.h:51:31: error: jemalloc/jemalloc.h: Nosuch file or directory

異常原因:一些編譯依賴或原來編譯遺留出現的問題

解決方案:make distclean。清理一下,然後再make。

異常三:在make成功以後,需要make test。在make test出現異常。

couldn‘t execute "tclsh8.5":no such file or directory

異常原因:沒有安裝tcl

解決方案:yum install -ytcl

 

三、安裝phpredis服務

1、解壓壓縮包

       tar –zxf php redis拓展為redis-2.2.7.tgz

2、進入解壓的目錄,執行phpize

[[email protected] phpredis]#/usr/local/php/bin/phpize


3、安裝phpredis拓展

[[email protected]]# ./configure --enable-redis --enable-redis-igbinary--with-php-config=/usr/local/php/bin/php-config

[[email protected]]# make && make install


4、修改php.ini檔案,載入對應redis拓展


5、重啟php,驗證是否安裝redis拓展

[[email protected] etc]# pkill -9 php

[[email protected] etc]# ../sbin/php-fpm

6、使用php,測試redis服務

<?php

echo‘xiaobei‘;

$redis= new Redis();

//進行串連

$redis->connect(‘127.0.0.1‘,6379);

$redis->set(‘name‘,‘redisis ok‘);

echo$redis->get(‘name‘);

?>

 

7、常見異常及處理

       異常一: checking for igbinary includes...configure: error: Cannot find igbinary.h

解決方案

下載http://pecl.php.net/get/igbinary-1.1.1.tgz

tar -xzvf igbinary-1.1.1.tgz

cd igbinary-1.1.1

phpize

./configure --with-php-config=/usr/local/php/bin/php-config--enable-igbinary

make

make install

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

小貝_redis安裝與部署

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.