Home >Database >Mysql Tutorial >Redis+phpredis配置

Redis+phpredis配置

WBOY
WBOYOriginal
2016-06-07 16:30:321043browse

Redis 官方文档都是好东西!~Redis Quick Start 先下载安装 wget http://download.redis.io/redis-stable.tar.gztar xvzf redis-stable.tar.gzcd redis-stablemakemake install 如果redis-server, redis-cli已经在 /usr/local/bin/ 则略过这一步~ sudo cp red

Redis
官方文档都是好东西!~Redis Quick Start

先下载安装

wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable
make
make install

如果redis-server, redis-cli已经在

/usr/local/bin/
则略过这一步~
sudo cp redis-server /usr/local/bin/
sudo cp redis-cli /usr/local/bin/

配置init.d

sudo mkdir /etc/redis
sudo mkdir /var/redis
sudo cp utils/redis_init_script /etc/init.d/redis_6379
sudo cp redis.conf /etc/redis/6379.conf
sudo mkdir /var/redis/6379

修改

redis.conf
  • daemonize
    设置为
    yes
  • pidfile
    设置为
    /var/run/redis_6379.pid
  • logfile
    设置为
    /var/log/redis_6379.log
  • dir
    设置为
    /var/redis/6379
sudo update-rc.d redis_6379 defaults

最后启动redis:

/etc/init.d/redis_6379 start

phpredis
GitHub地址: phpredis
ReadMe有Installing, 不说了
然后在把redis.ini加入php就行了

sudo echo "extension=redis.so">/etc/php5/conf.d/redis.ini

重启服务器就ok了~

测试一下:

<?php $redis=new Redis();
        $res = $redis->connect('127.0.0.1', 6379);
        echo $res;
        //连接成功为True(或1), 失败为False(或0)
?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn