安裝php擴充phpredis

來源:互聯網
上載者:User
一、下載安裝包 redis下載

點擊下載redis http://download.redis.io/releases/redis-4.0.0.tar.gz

redis官網下載 點擊去官網 https://redis.io/

##linux下載[root@localhost ~]# wget http://download.redis.io/releases/redis-4.0.0.tar.gz
1 2
phpredis下載[php的擴充]

點擊下載 https://codeload.github.com/phpredis/phpredis/zip/develop

Github查看 redis https://github.com/phpredis/phpredis 二、安裝redis 安裝

[root@localhost home]# tar -zxvf redis-4.0.0.tar.gz[root@localhost home]# cd redis-4.0.0[root@localhost redis-4.0.0]# make
1 2 3

[root@localhost redis-4.0.0]# cd src[root@localhost src]# make install
1 2 3

Redis部署

安裝成功後,下面對Redis 進行部署

1、 首先為了方便管理,將Redis檔案中的設定檔和常用命令移動到統一檔案中。

[root@localhost ~]# mkdir –p /usr/local/redis/bin[root@localhost ~]# mkdir –p /usr/local/redis/etc[root@localhost ~]# cp /home/redis-4.0.0/redis.conf  /usr/local/redis/etc[root@localhost ~]# cp /home/redis-4.0.0/src/mkreleasehdr.sh  redis-benchmark redis-check-aof redis-cli redis-server redis-check-rdb redis-sentinel redis-trib.rb  /usr/local/redis/bin/
1 2 3 4 5

2 啟動redis-server服務

###修改redis設定檔[root@localhost ~]# vim /usr/local/redis/etc/redis.conf 修改daemonize 改為 yes (允許後台啟動)啟動redis並且指定啟動的設定檔[root@localhost ~]# /usr/local/redis/bin/redis-server  /usr/local/redis/etc/redis.conf
1 2 3 4 5

查看redis是否啟動

[root@localhost ~]# ps aux | grep redis              查看redis是否啟動成功root       4046  0.0  0.2 145248  7568 ?        Ssl  13:35   0:00 ./redis-server 127.0.0.1:6379root       4096  0.0  0.0 112664   968 pts/2    S+   13:53   0:00 grep --color=auto redis
1 2 3 4

其他命令

redis-cli                     開啟redis的用戶端    quit                          退出redis的用戶端pkill redis-server            關閉redis伺服器redis-cli shutdown            關閉redis伺服器
1 2 3 4 5 6 7

查看redis連接埠是否被監聽

[root@localhost ~]# netstat -tlun                        查看主機的6379連接埠是否在使用(監聽)Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address           Foreign Address         State      tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN     tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN   
1 2 3 4 5
三、安裝php擴充 phpredis
[root@localhost ~]# unzip phpredis-develop.zip[root@localhost ~]# cd phpredis-develop##重新編譯phpize:/usr/local/php7/bin/phpize(無需切換目錄,直接執行自己找到的phpize)[root@localhost phpredis-develop]# find / -name 'phpize'/usr/local/mysoftware/php7/bin/phpize ##一般是在你安裝的php目錄裡面的[root@localhost phpredis-develop]# /usr/local/mysoftware/php7/bin/phpize ##執行一下,此時在phpredis-develop目錄下多一個configure
1 2 3 4 5 6 7 8 9
##找到php-config:find / -name 'php-config'[root@localhost phpredis-develop]# find / -name 'php-config'/home/php-7.0.4/scripts/php-config[root@localhost phpredis-develop]# ./configure --with-php-config=/home/php-7.0.4/scripts/php-config(不用切換目錄,把找到的php-config路徑填到此命令的參數裡)[root@localhost phpredis-develop]# make && make install
1 2 3 4 5 6

修改php.ini設定檔

加上這句extension=redis.so
1 2

重啟php就可以看到redis擴充已經安裝上了

redis其他配置資訊

daemonize                如果需要將Redis服務以守護進程在後台運行,則把該項的值改為yespidfile                  配置多個pid的地址,預設在/var/run/redis/pidbind                     綁定ip,設定後只接受來自該ip的請求port                     監聽連接埠,預設是6379timeout                  用戶端連線逾時的設定,單位是秒loglevel                 分為4級,debug、verbose、notice、warninglogfile                  配置log檔案地址databases                設定資料庫的個數,預設使用的資料庫為0save                     設定redis進行資料庫鏡像的頻率rdbcompression           在進行鏡像備份時,是否進行壓縮Dbfilename               鏡像備份檔案的檔案名稱Dir                      資料庫鏡像備份檔案的存放路徑Slaveof                  設定資料庫為其他資料庫的從資料庫Masterauth               主要資料庫串連需要的密碼驗證Requirepass              設定登入時,需要使用的密碼Maxclients               設定同時串連的最大用戶端數量Maxmemory                設定redis能夠使用的最大記憶體Appendonly               開啟append only模式Appendfsync              設定對appendonly.aof檔案同步的頻率vm-enabled               是否開啟虛擬記憶體支援vm-swap-file             設定虛擬記憶體的分頁檔路徑vm-max-memory            設定redis能夠使用的最大虛擬記憶體vm-page-size             設定虛擬記憶體的頁大小vm-pages                 設定分頁檔的總的page數量vm-max-threads           設定VMIO同時使用的線程數量Glueoutputbuf            把小的輸出緩衝存放在一起hash-max-zipmap-entries  設定hash的臨界值Activerehashing          重新hash
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 著作權聲明:本文為博主原創文章,未經博主允許不得轉載。 https://blog.csdn.net/post_mans/article/details/78519128

聯繫我們

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