++++++++++++++++++++++++++++++++++++++++++++++
linux下Redis与phpredis扩展安装
++++++++++++++++++++++++++++++++++++++++++++++
操作系统 : [CentOS6.0]
redis : [redis-2.4.3]
phpredis : [phpredis-2.1.0]
++++++++++++++++++++++++++++++++++++++++++++++
准备安装软件(download)
1> [redis]
http://redis.googlecode.com/files/redis-2.4.3.tar.gz
2> [phpredis]
https://github.com/owlient/phpredis/tarball/master
++++++++++++++++++++++++++++++++++++++++++++++
1>【安装redis服务器】
- tar -zxvf redis-2.4.3.tar.gz
- cp -r redis-2.4.3 /usr/local/redis
- cd /usr/local/redis
- make
- make install
- cp redis.conf /etc/
- #修改redis.conf
- vi /etc/redis.conf
- #查找daemonize no改为
- #以守护进程方式运行
- daemonize yes
- #修改dir ./为绝对路径,
- #默认的话redis-server启动时会在当前目录生成或读取dump.rdb
- #所以如果在根目录下执行redis-server /etc/redis.conf的话,
- #读取的是根目录下的dump.rdb,为了使redis-server可在任意目录下执行
- #所以此处将dir改为绝对路径
- dir /usr/local/redis
- #修改appendonly为yes
- #指定是否在每次更新操作后进行日志记录,
- #Redis在默认情况下是异步的把数据写入磁盘,
- #如果不开启,可能会在断电时导致一段时间内的数据丢失。
- #因为 redis本身同步数据文件是按上面save条件来同步的,
- #所以有的数据会在一段时间内只存在于内存中。默认为no
- appendonly yes
- #将redis添加到自启动中
- echo "/usr/local/bin/redis-server /etc/redis.conf" >> /etc/rc.d/rc.local
- #启动redis
- redis-server /etc/redis.conf
- #查看redis是否己启动
- ps -ef | grep redis
2>【开放redis端口】
- #关闭防火墙
- service iptables stop
- vi /etc/sysconfig/iptables
- #添加
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT
- #重启防火墙
- service iptables restart
3>【安装phpredis扩展】
- tar -zxvf owlient-phpredis-2.1.1-1-g90ecd17.tar.gz
- cd owlient-phpredis-90ecd17
- /usr/local/php/bin/phpize
- ./configure --with-php-config=/usr/local/php/bin/php-config
- make
- make install
- #执行完make install后会生成
- #Installing shared extensions: /usr/local/php//lib/php/extensions/no-debug-non-zts-20060613/
- #修改php.ini
- vi /usr/local/php/etc/php.ini
- #查找extension_dir,修改为
- extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
- #添加redis
- extension = redis.so
- #重启apache
- service httpd restart