lnmp 安装php reds 扩展篇

[转载于http://www.osyunwei.com/archives/7210.html]

Linux下php安装Redis扩展

1、安装编译工具

yum install wget  make gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel kernel keyutils  patch perl

2、安装redis

开始下载

wget https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz

(可以直接 cd /usr/local/src 再进行下载)

tar zxvf phpredis-2.2.4.tar.gz(你可以看到的只有2.24.tar.gz)#解压

cd phpredis-2.2.4 #进入安装目录

/usr/local/php/bin/phpize #用phpize生成configure配置文件

(可能会出现-bash: /usr/local/php/bin/phpize: No such file or directory这个错误  原因是phpize地址错误

先find / -name phpize  找到正确地址 如   /usr/bin/phpize)

(可能执行 正确地址的phpize还是还报错误

Can't find PHP headers in /usr/include/php
The php-devel package is required for use of this command.

原因很明确  却少 php-devel

 yum install php-devel

)

./configure --with-php-config=/usr/local/php/bin/php-config  #配置

(可能会报错 

checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure: error: Cannot find php-config. Please use --with-php-config=PATH


原因是 php-config的地址不错,那么我们做的是find / -name php-config 得到正确地址之后重新 配置

./configure --with-php-config=/usr/bin/php-config
)

make  #编译

make install  #安装

安装完成之后,出现下面的安装路径

Installing shared extensions:     /usr/lib64/php/modules/

3、配置php支持

vi /usr/local/php/etc/php.ini  #编辑配置文件,在最后一行添加以下内容

添加

extension="redis.so"

:wq! #保存退出

4、测试

vi /usr/local/nginx/html/index.php   #编辑

<?php

phpinfo();

?>

:wq! #保存退出

 

posted @ 2017-07-18 14:52  ddxg  阅读(369)  评论(0编辑  收藏  举报