CentOS 7 安裝 Redis,使用hiredis操作數據庫

  1. 安裝redis server
    1. 下載redis: wget http://download.redis.io/releases/redis-3.0.0.tar.gz 
    2. tar zxvf redis-3.0.0.tar.gz
    3. 編譯時依賴的庫 編譯redis時 提示make cc Command not found
      1. yum install gcc
      2. yum install tcl
    4. cd redis-3.0.0 taskset -c 1 sudo make MALLOC=libc test
    5. make install
    6. cd src
    7. redis-server &
  2. 安裝hiredis(程序依賴庫)
    1. 下載hiredis(通過git網頁直接下載): https://github.com/redis/hiredis/tree/v0.13.3
    2. 解壓 unzip hiredis-0.13.3.zip
    3. cd hiredis-0.13.3
    4. 執行安裝指令
      1. make
      2. make install
    5. 安裝完畢後執行ldconfig刷新緩存 ldconfig
  3. 編譯運行時報錯 問題:error while loading shared libraries: libhiredis.so.0.13: cannot open shared object file: No such file or directory 解決方案: 確保/etc/ld.so.conf裏面有 /usr/local/lib 這一行,沒有的話vim編輯在尾行加上 然後:sudo ldconfig
  4. 代碼參考:https://github.com/kelvin7feng/redis_wrapper
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章