phpredis -- PHP 7 安裝 Redis 擴充

來源:互聯網
上載者:User

標籤:phpredis php7   redis 擴充   報錯   git 分支

前提是已經安裝好 Redis 和 PHP7 了。


  1. 下載phpredis 

phpredis項目的GitHub頁面是 https://github.com/phpredis/phpredis 

但是有個問題,php7 的redis擴充項目和php5的redis擴充項目代碼並不通用,所以在phpredis項目下有個新的支援php7版本的分支,但是你預設clone的項目是停留在原版php5的項目中的,所以需要手動檢出到php7的分支

git clone //將遠程項目程式碼複製品到本地cd phpredis

我們查看下代碼分支結構

650) this.width=650;" src="http://s5.51cto.com/wyfs02/M02/87/16/wKiom1fTkGbwIKuRAABgkaz4NU4898.png-wh_500x0-wm_3-wmp_4-s_3317847083.png" title="2.png" alt="wKiom1fTkGbwIKuRAABgkaz4NU4898.png-wh_50" />

可以看到遠程分支上有一個 php7 的分支,這個就是單獨支援PHP 7的phpredis擴充

git checkout -b php7  origin/php7//我們本地建立php7分支,其實節點為遠端php7分支git branch//這就可以看到我們目前處在新建立的 php7 分支上

650) this.width=650;" src="http://s2.51cto.com/wyfs02/M02/87/14/wKioL1fTkS2i0yf_AAANPpjp-uY957.png" title="3.png" alt="wKioL1fTkS2i0yf_AAANPpjp-uY957.png" />

ps:如果有人對命令提示字元上面的[>php7] 分支提示感興趣的話,可以瀏覽我之前的文章:個性定製你的 Git 命令列提示符 http://professor.blog.51cto.com/996189/1737500    



2.開始編譯phpredis擴充

phpize//檢查php擴充./configure --with-php-config=/usr/local/php7/bin/php-config//我這裡是編譯安裝的PHP 7 所以需要手動指定php-config的路徑//如果你需要開啟igbinary序列化支援的話,需要加上參數 --enable-redis-igbinarymakemake install



3.安裝配置phpredis擴充

檢查redis.so 庫檔案是否存在

650) this.width=650;" src="http://s5.51cto.com/wyfs02/M01/87/17/wKiom1fTln3iGB25AAAhUoqf5HU766.png" title="4.png" alt="wKiom1fTln3iGB25AAAhUoqf5HU766.png" />

修改php.ini設定檔

vim  /usr/local/php7/lib/php.iniextention="redis.so"//添加這一行擴充配置php -a>phpinfo();//檢查是否有redis的相關資訊

650) this.width=650;" src="http://s5.51cto.com/wyfs02/M00/87/17/wKiom1fTmLSysH4dAAAHbalGxWs940.png" title="5.png" alt="wKiom1fTmLSysH4dAAAHbalGxWs940.png" />

service php-fpm restart//重啟php-fpm服務

到此,phpredis 就安裝完成了,所以最關鍵的一步就是 PHP 7 安裝redis擴充庫是需要在本地切換分支節點的。


本文出自 “Professor哥” 部落格,請務必保留此出處http://professor.blog.51cto.com/996189/1851370

phpredis -- PHP 7 安裝 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.