Centos7 安装phpredis拓展

 

 

参考:https://blog.csdn.net/wplblog/article/details/52195041

1:

Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script.

运行/usr/local/webserver/php/bin/phpize时出现:
Configuring for:
PHP Api Version:         20041225
Zend Module Api No:      20060613
Zend Extension Api No:   220060519
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.
根据网上的解决办法是:

# cd /usr/src
# wget http://ftp.gnu.org/gnu/m4/m4-1.4.9.tar.gz
# tar -zvxf m4-1.4.9.tar.gz
# cd m4-1.4.9/
# ./configure && make && make install
# cd ../
# wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.62.tar.gz
# tar -zvxf autoconf-2.62.tar.gz
# cd autoconf-2.62/
# ./configure && make && make install



更简单的办法
# yum install m4
# yum install autoconf

 

 

  1. 第一步:开始在 PHP 中使用 Redis 前,我们需要确保已经安装了 redis 驱动,且你的机器上能正常使用 PHP。接下来让我们安装 PHP redis 驱动

  2. //redis扩展的下载地址 有时候可能链接不上 毕竟是人家的下载源

  3.  [root@localhost wengpengle]# wget https://github.com/phpredis/phpredis/archive/2.2.8.tar.gz

  4.  
  5. //解压刚刚下载好的压缩包

  6.  [root@localhost wengpengle]# tar -zxvf 2.2.8.tar.gz

  7. //进入主目录

  8.  [root@localhost wengpengle]# cd phpredis-2.2.8/

  9. //执行完这一步(用phpize生成configure配置文件) 会出现下面的错误 根据错误提示 可以看出 没有 php-devel 这个扩展

  10. [root@localhost phpredis-2.2.8]# /usr/bin/phpize

  11.  
  12. Can't find PHP headers in /usr/include/php

  13. The php-devel package is required for use of this command.

  14.  
  15.  //安装 php-devel 会有以下提示

  16. [root@localhost phpredis-2.2.8]# yum install php-devel

  17. Another app is currently holding the yum lock; waiting for it to exit...

  18.   另一个应用程序是:PackageKit

  19.     内存:147 M RSS (477 MB VSZ)

  20.     已启动: Sun Aug 14 18:35:24 2016 - 58:34之前

  21.     状态  :睡眠中,进程ID:3620

  22.  
  23. //杀死进程

  24. [root@localhost phpredis-2.2.8]# kill -9 3620

  25.  
  26. //继续安装 php-devel 如果还提示 有一个进程、就继续杀死、知道没有提示为止。如果没有提示就 根据下载提示、一路属于 y 即可

  27. [root@localhost phpredis-2.2.8]# yum install php-devel

  28. //出现以下提示 代表安装成功

  29.  
  30. 已安装:

  31.   php-devel.x86_64 0:5.4.16-36.3.el7_2                                                  

  32.  
  33. 作为依赖被安装:

  34.   pcre-devel.x86_64 0:8.32-15.el7_2.1                                                   

  35.  
  36. 作为依赖被升级:

  37.   pcre.x86_64 0:8.32-15.el7_2.1                                                         

  38.  
  39. 完毕!

  40.  
  41. //在执行 /usr/bin/phpize 这个密令、意思就是(用phpize生成configure配置文件)、 出现以下提示、说明 OK 了

  42. [root@localhost phpredis-2.2.8]# /usr/bin/phpize

  43. Configuring for:

  44. PHP Api Version:         20100412

  45. Zend Module Api No:      20100525

  46. Zend Extension Api No:   220100525

  47.  
  48. //查看php-config 的路径

  49. [root@localhost phpredis-2.2.8]# whereis php-config

  50.  
  51. php-config: /usr/bin/php-config /usr/share/man/man1/php-config.1.gz

  52.  
  53. //配置

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

  55.  
  56. //编译并且安装、(出现以下提示说明 OK)

  57. [root@localhost phpredis-2.2.8]# make && make instahttps://blog.csdn.net/wplblog/article/details/52195041ll

  58. Build complete.

  59. Don't forget to run 'make test'.

  60.  
  61. Installing shared extensions:     /usr/lib64/php/modules/

  62.  
  63. //修改php.ini配置文件 让php支持redis

  64. [root@localhost phpredis-2.2.8]#vi /etc/php.ini

  65. //在 php.ini 的最后一行加上

  66. extension=redis.so

  67.  
  68. ; directive because it is not set or is mistyped, a default value will be used.

  69. extension=redis.so (加上)

  70. ; The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one

  71. ; of the INI constants (On, Off, True, False, Yes, No and None) or an expression

  72. ; (e.g. E_ALL & ~E_NOTICE), a quoted string ("bar"), or a reference to a

  73. ; previously set variable or directive (e.g. ${foo})

  74.  
  75. ; Expressions in the INI file are limited to bitwise operators and parentheses:

  76. ; |  bitwise OR

  77. ; ^  bitwise XOR

  78. ; &  bitwise AND

  79. :wq (保存并退出)

  80.  
  81. //如果安装的是 lamp 的环境、则重行启动 Apache

  82. [root@localhost etc]# systemctl restart httpd

  83.  
  84. //如果安装的是 lnmp 的环境、则重新启动 php-fpm

  85. [root@localhost html]# systemctl restart php-fpm

  86.  
  87.  
  88. 完毕!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值