php搭建redis擴充安裝及配置

來源:互聯網
上載者:User

標籤:style   http   使用   os   io   檔案   資料   for   

     1:redis 安裝   

  $ wget http://download.redis.io/releases/redis-2.8.13.tar.gz  $ tar xzf redis-2.8.13.tar.gz  $ cd redis-2.8.13  $ make

2:運行redis 載入redis的設定檔redis.conf
編譯後的可執行檔在src目錄中,可以使用下面的命令運行Redis:  $ src/redis-server redis.conf  你可以使用內建的用戶端串連Redis:  $ src/redis-cli  redis> set foo bar  OK  redis> get foo  "bar"

3:redis配置

 
(這個是我個人的配置,根據自己的需求配置即可,配置完記得重新啟動redis並載入配置)  # daemonize no 預設情況下,redis不是在後台啟動並執行,如果需要在後台運行,把該項的值更改為yes    daemonize yes  # 當redis在後台啟動並執行時候,Redis預設會把pid檔案放在/var/run/redis.pid,你可以配置到其他地址。  pidfile /var/run/redis.pid  # 指定redis啟動並執行連接埠,預設是6379  port 6379  # 指定redis只接收來自於該IP地址的請求,如果不進行設定,那麼將處理所有請求,  # 在生產環境中最好設定該項  # bind 127.0.0.1  # 設定用戶端串連時的逾時時間,單位為秒。當用戶端在這段時間內沒有發出任何指令,那麼關閉該串連  # 0是關閉此設定  timeout 0  # 指定日誌記錄層級  # Redis總共支援四個層級:debug、verbose、notice、warning,預設為verbose  # debug記錄很多資訊,用於開發與測試  # varbose有用的資訊,不像debug會記錄那麼多  # notice普通的verbose,常用於生產環境  # warning只有非常重要或者嚴重的資訊會記錄到日誌  loglevel debug  # 配置log檔案地址  # 預設值為stdout,標準輸出,若後台模式會輸出到/dev/null  #logfile stdout  logfile /var/log/redis/redis.log  # 可用資料庫數  # 預設值為16,預設資料庫為0,資料庫範圍在0-(database-1)之間  databases 16  ################################ 快照 #################################  #  # 儲存資料到磁碟,格式如下:  #  #   save <seconds> <changes>  #  #   指出在多長時間內,有多少次更新操作,就將資料同步到資料檔案rdb。  #   相當於條件觸發抓取快照,這個可以多個條件配合  #      #   比如預設設定檔中的設定,就設定了三個條件  #  #   save 900 1  900秒內至少有1個key被改變  #   save 300 10  300秒內至少有300個key被改變  #   save 60 10000  60秒內至少有10000個key被改變  save 900 1  save 300 10  save 60 10000  # 儲存至本機資料庫時(持久化到rdb檔案)是否壓縮資料,預設為yes  rdbcompression yes  # 本地持久化資料庫檔案名,預設值為dump.rdb  dbfilename dump.rdb  # 工作目錄  #  # 資料庫鏡像備份的檔案放置的路徑。  # 這裡的路徑跟檔案名稱要分開配置是因為redis在進行備份時,先會將當前資料庫的狀態寫入到一個臨時檔案中,等備份完成時,  # 再把該該臨時檔案替換為上面所指定的檔案,而這裡的臨時檔案和上面所配置的備份檔案都會放在這個指定的路徑當中。  #  # AOF檔案也會存放在這個目錄下面  #  # 注意這裡必須制定一個目錄而不是檔案  dir ./  ################################# 複製 #################################    # 設定同一時間最大用戶端串連數,預設無限制,Redis可以同時開啟的用戶端串連數為Redis進程可以開啟的最大檔案描述符數,  # 如果設定 maxclients 0,表示不作限制。  # 當用戶端串連數到達限制時,Redis會關閉新的串連並向用戶端返回max number of clients reached錯誤資訊  #  # maxclients 128
4:php上面安裝redis擴充
  $ wget https://github.com/owlient/phpredis/archive/master.zip  $ unzip phpredis-master  $ cd phpredis-master  $ /usr/local/webserver/php/bin/phpsize (你的php安裝目錄下的bin下的phpsize)  $ ./configure --with-php-config=/usr/local/webserver/php/bin/php-config  $ make  $ make install
5:修改php的設定檔php.ini
  $ vim /usr/local/webserver/php/php.ini (你的php設定檔 php.ini)  添加一條配置:extension=redis.so  重啟apache或者nginx

6:安裝過程可能出現的問題
  Configuring for:  PHP Api Version:         20041225  Zend Module Api No:      20060613  Zend Extension Api No:   220060519  Cannot find autoconf. Please check your autoconf installation and the  $PHP_AUTOCONF  environment variable is set correctly and then rerun this script.  解決辦法:  $ wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz  $ tar -zvxf m4-1.4.9.tar.gz  $ cd m4-1.4.9/  $ ./configure && make && make install  $ cd ../  $ wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz  $ tar -zvxf autoconf-2.62.tar.gz  $ cd autoconf-2.62/  $ ./configure && make && make install



 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.