一、安装redis

下载最新版

wget http://download.redis.io/redis-stable.tar.gz

解压编译

tar zxvf redis-2.4.17.tar.gz  
cd redis-2.4.17  
make  
make PREFIX=/usr/local/webserver/redis install

配置redis

mkdir /etc/redis  
cp redis.conf  /etc/redis/redis.conf  
mkdir /var/lib/redis

拷贝命令文件

cp redis-server /usr/local/bin/
cp redis-cli /usr/local/bin/

修改配置信息

# 然后新建目录,存放配置文件
mkdir /etc/redis
mkdir /var/redis
mkdir /var/redis/log
mkdir /var/redis/run
mkdir /var/redis/6379
# 在redis解压根目录中找到配置文件模板,复制到如下位置。
cp redis.conf /etc/redis/6379.conf
# 通过vim命令修改
daemonize yes  #介个是设置服务在后台运行
pidfile /var/redis/run/redis_6379.pid
logfile /var/redis/log/redis_6379.log
dir /var/redis/6379
8.redis-server /etc/redis/6379.conf  运行redis

 

二、安装PHP扩展

git clone:

git clone  https://github.com/phpredis/phpredis.git

GitHub: https://github.com/phpredis/phpredishttps://github.com/phpredis/phpredis

GitHub: https://github.com/phpredis/phpredis/tree/php7 (PHP7 redis 扩展)

phpredis-php7.ziphttps://github.com/phpredis/phpredis/archive/php7.zip

切换分支:

git checkout -b php7 origin/php7

检查PHP扩展

/usr/local/php7/bin/phpize

建立编译连接

./configure --with-php-config=/usr/local/php7/bin/php-config

make

make

make test

make test

安装

make install

检查so文件

 cd /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/
 ls

修改php.ini

vi /usr/local/php7/etc/php.ini

添加:extension="redis.so"

 

三:重启

sudo service nginx restart
sudo /etc/init.d/php-fpm restart

 

四、测试

make test

 

附加扩展

pdo_mysql 扩展

cd /home/data/tool-server/LNMP/php-7.0.13/ext/pdo_mysql/
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/bin/mysql_config
make && make install

 

安装结果:

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/

# ll /usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/
total 13376
-rwxr-xr-x 1 root root   50942 Jan  7 18:02 ctype.so
-rwxr-xr-x 1 root root  306407 Jan  7 17:58 curl.so
-rwxr-xr-x 1 root root 1209496 Jan  7 18:00 gd.so
-rwxr-xr-x 1 root root   52949 Jan  7 18:06 gettext.so
-rwxr-xr-x 1 root root  171993 Jan  7 18:02 iconv.so
-rwxr-xr-x 1 root root 1330602 Jan  7 14:12 imagick.so
-rwxr-xr-x 1 root root  219369 Jan  7 18:03 json.so
-rwxr-xr-x 1 root root 3079856 Jan  7 18:04 mbstring.so
-rwxr-xr-x 1 root root  504709 Jan  7 14:45 memcache.so
-rwxr-xr-x 1 root root 2016099 Jan  7 14:41 mongo.so
-rwxr-xr-x 1 root root 1954452 Nov 11 21:08 opcache.a
-rwxr-xr-x 1 root root  911578 Nov 11 21:08 opcache.so
-rwxr-xr-x 1 root root  172581 Jan  7 19:35 pdo_mysql.so
-rwxr-xr-x 1 root root 1688817 Jan  7 19:14 redis.so

 

 

参考推荐

LNMP(CentOS+Nginx+Mysql+PHP)服务器环境配置

Nginx和PHP-FPM的启动、重启、停止脚本

Linux php7安装mongoDB和memcached扩展