一、安装 redis

可参见米扑博客:Centos Redis 安装配置和启动脚本Mac OS X 安装 Redis

1)下载最新版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/redis install

2)配置 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/

3)修改配置信息
# 然后新建目录,存放配置文件
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

4)运行redis
redis-server /etc/redis/6379.conf

 

二、安装PHP扩展 phpredis

GitHub: https://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 clone  https://github.com/phpredis/phpredis.git

git checkout -b php7 origin/php7
检查PHP扩展
/usr/local/php7/bin/phpize
建立编译连接
./configure --with-php-config=/usr/local/php7/bin/php-config
make
make test
安装
make install
检查so文件
ls -l /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/
修改php.ini
vi /usr/local/php7/etc/php.ini
添加:extension="redis.so"

 

三、重启 nginx
sudo service nginx restart
sudo /etc/init.d/php-fpm restart

 

四、测试
make test
附加扩展 pdo_mysql

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

 

参考推荐

Centos Redis 安装配置和启动脚本

Mac OS X 安装 Redis

Mac 开机启动MySQL/MongoDB/Redis 等服务

Linux 配置 nginx、mysql、php-fpm、redis 开机启动

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

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

Linux php7安装mongoDB和memcached扩展

CentOS 7.2 / 6.5 系统安装指引 (推荐