lnmp Fatal error: Uncaught Error: Class 'Redis' not found

搬运,写的不错!
https://blog.51cto.com/leoheng/2162621

1.下载扩展包
链接:https://pan.baidu.com/s/1WHcLFOD0SaaRZlgD50yvWQ 密码:zmto

2.创建放压缩包的目录,并解压

[root@com source]# pwd
/server/source
[root@com source]# tar -xf 2.2.4.tar.gz
[root@com source]# cd
lnmp1.4/ phpredis-2.2.4/
[root@com source]# cd phpredis-2.2.4/
[root@com phpredis-2.2.4]#

3.使用phpize生成configure配置文件

[root@com phpredis-2.2.4]# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226
[root@com phpredis-2.2.4]#

4.预编译

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

5.编译安装

[root@com phpredis-2.2.4]# make && make install

报错看这里:
https://blog.csdn.net/jartins/article/details/80371257

6.修改php.ini配置文件,支持redis动态库(重点)

[root@com phpredis-2.2.4]# vim /usr/local/php/etc/php.ini
extension=“redis.so” #最后一行添加

  1. 重启PHP服务

[root@com phpredis-2.2.4]# lnmp restart
±------------------------------------------+
| Manager for LNMP, Written by Licess |
±------------------------------------------+
| https://lnmp.org |
±------------------------------------------+
Stoping LNMP…
Stoping nginx… done
Shutting down MySQL… SUCCESS!
Gracefully shutting down php-fpm . done
Starting LNMP…
Starting nginx… done
Starting MySQL… SUCCESS!
Starting php-fpm done
[root@com phpredis-2.2.4]#

https://stackoverflow.com/questions/24858704/phpredis-errors-class-redis-not-found-in-linux

测试安装是否成功代码:

php -r "if (new Redis() == true){ echo \"\r\n OK \r\n\"; }"

你可能感兴趣的:(运维)