Linux 下Centos7 PHP使用redis 安裝redis擴充

來源:互聯網
上載者:User
第一步:開始在 PHP 中使用 Redis 前,我們需要確保已經安裝了 redis 驅動,且你的機器上能正常使用 PHP。接下來讓我們安裝 PHP redis 驅動  //redis擴充的下載地址 有時候可能連結不上 畢竟是人家的下載源 [root@localhost wengpengle]# wget https://github.com/phpredis/phpredis/archive/2.2.8.tar.gz  //解壓剛剛下載好的壓縮包 [root@localhost wengpengle]# tar -zxvf 2.2.8.tar.gz  //進入主目錄 [root@localhost wengpengle]# cd phpredis-2.2.8/  //執行完這一步(用phpize產生configure設定檔) 會出現下面的錯誤   根據錯誤提示 可以看出 沒有 php-devel 這個擴充  [root@localhost phpredis-2.2.8]# /usr/bin/phpize  Can't find PHP headers in /usr/include/php  The php-devel package is required for use of this command. //安裝 php-devel  會有以下提示   [root@localhost phpredis-2.2.8]# yum install php-devel  Another app is currently holding the yum lock; waiting for it to exit...  另一個應用程式是:PackageKit    記憶體:147 M RSS (477 MB VSZ)    已啟動: Sun Aug 14 18:35:24 2016 - 58:34之前    狀態  :睡眠中,進程ID:3620  //殺死進程  [root@localhost phpredis-2.2.8]# kill -9 3620  //繼續安裝 php-devel 如果還提示 有一個進程、就繼續殺死、知道沒有提示為止。如果沒有提示就 根據下載提示、一路屬於 y 即可  [root@localhost phpredis-2.2.8]# yum install php-devel  //出現以下提示 代表安裝成功     已安裝:  php-devel.x86_64 0:5.4.16-36.3.el7_2                                                     作為依賴被安裝:  pcre-devel.x86_64 0:8.32-15.el7_2.1                                                      作為依賴被升級:  pcre.x86_64 0:8.32-15.el7_2.1                                                            完畢。      //在執行 /usr/bin/phpize  這個密令、意思就是(用phpize產生configure設定檔)、 出現以下提示、說明 OK 了   [root@localhost phpredis-2.2.8]# /usr/bin/phpize   Configuring for:   PHP Api Version:         20100412   Zend Module Api No:      20100525   Zend Extension Api No:   220100525    //查看php-config 的路徑  [root@localhost phpredis-2.2.8]# whereis php-config  php-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz    //配置  [root@localhost phpredis-2.2.8]# ./configure --with-php-config=/usr/bin/php-config    //編譯並且安裝、(出現以下提示說明 OK)  [root@localhost phpredis-2.2.8]# make && make instll  Build complete.  Don't forget to run 'make test'.  Installing shared extensions:     /usr/lib64/php/modules/ //修改php.ini設定檔 讓php支援redis   [root@localhost phpredis-2.2.8]#vi /etc/php.ini  //在 php.ini 的最後一行加上 extension=redis.so; directive because it is not set or is mistyped, a default value will be used.extension=redis.so (加上); The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one; of the INI constants (On, Off, True, False, Yes, No and None) or an expression; (e.g. E_ALL & ~E_NOTICE), a quoted string ("bar"), or a reference to a; previously set variable or directive (e.g. ${foo}); Expressions in the INI file are limited to bitwise operators and parentheses:; |  bitwise OR; ^  bitwise XOR; &  bitwise AND:wq (儲存並退出)  //如果安裝的是 lamp 的環境、則重行啟動 Apache  [root@localhost etc]# systemctl restart httpd  //如果安裝的是 lnmp 的環境、則重新啟動 php-fpm [root@localhost html]# systemctl restart php-fpm完畢。


 


聯繫我們

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