CentOS7配置php7.0支持redis


配置之前應該是環境已經搭好了,phpinfo的頁面可以加載出來。

使用git clone下載git上的phpredis擴展包

[root@VM_103_117_centos ]#git clone  https://github.com/phpredis/phpredis.git

到了這一步,我們要使用安裝php時生成的phpize來生成configure配置文件,

//具體用哪個要取決於你的phpize文件所在的目錄,這時你應該用 whereis phpize 來查看路徑

[root@VM_103_117_centos phpredis]# whereis phpize
phpize: /usr/bin/phpize /usr/share/man/man1/phpize.1.gz

這里表明路徑為/usr/bin/phpize,然后執行:

[root@VM_103_117_centos phpredis]# /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,由於我是使用的php7.0所以執行以下命令:

[root@VM_103_117_centos phpredis]#yum -y install php70w-devel

然后再次執行:

[root@VM_103_117_centos phpredis]# /usr/bin/phpize
Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012

執行完上一步,我們就有了 configure 配置文件了,接下來配置

[root@VM_103_117_centos phpredis]#./configure

或者執行

[root@VM_103_117_centos phpredis]#./configure --with-php-config=/usr/bin/php-config

接下來是編譯安裝

[root@VM_103_117_centos phpredis]#make 

[root@VM_103_117_centos phpredis]# make install
Installing shared extensions: /usr/lib64/php/modules/

配置php的配置文件php.ini(具體放在那里可以用 whereis php.ini 來查看),我的配置文件php.ini在/etc/下

[root@VM_103_117_centos phpredis]#vim /etc/php.ini

加入下面幾行:

[redis]
extension_dir =/usr/lib64/php/modules/
extension = redis.so

redis.so文件的路徑可以在make install的時候看到

重啟apache服務器,使配置生效

[root@VM_103_117_centos phpredis]#systemctl restart httpd.service

重啟之后我們打開info.php,已經可以看到redis的擴展信息了

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM