<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>运达&#039;s  blog &#187; ctl</title>
	<atom:link href="https://www.yunda51.com/?feed=rss2&#038;tag=ctl" rel="self" type="application/rss+xml" />
	<link>https://www.yunda51.com</link>
	<description>运达的博客</description>
	<lastBuildDate>Wed, 12 Nov 2025 07:58:26 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0.19</generator>
	<item>
		<title>CentOs下Redis的安装，配置以及phpredis扩展</title>
		<link>https://www.yunda51.com/?p=1593</link>
		<comments>https://www.yunda51.com/?p=1593#comments</comments>
		<pubDate>Thu, 13 Aug 2015 08:21:43 +0000</pubDate>
		<dc:creator><![CDATA[运达]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[ctl]]></category>
		<category><![CDATA[redis]]></category>

		<guid isPermaLink="false">http://www.yunda51.com/?p=1593</guid>
		<description><![CDATA[1、安装需要的支持环境 在安装Redis之前首要先做的是安装Unix的Tcl工具，如果不安装的话后期将无法对R<a href="https://www.yunda51.com/?p=1593" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>1、安装需要的支持环境</p>
<p>在安装Redis之前首要先做的是安装Unix的Tcl工具，如果不安装的话后期将无法对Redis进行测试。在后期执行make test的时候返回如下错误信息：You need tcl 8.xuyao de5 or newer in order to run the Redis test，具体的流程为：</p>
<pre class="wp-code-highlight prettyprint">cd /usr/local/src
wget http://downloads.sourceforge.net/tcl/tcl8.6.3-src.tar.gz
tar -zxvf tcl8.6.3-src.tar.gz
cd ​tcl8.6.3/unix/
./configure
make
make install
</pre>
<p>2、安装redis。<br />
先下在redis，下载地址：http://redis.io/download</p>
<pre class="wp-code-highlight prettyprint">cd /usr/local/src
wget http://download.redis.io/releases/redis-2.8.19.tar.gz
tar zxvf redis-2.8.19.tar.gz
cd redis-2.8.19
make
make PREFIX=/usr/local/redis install
</pre>
<p>3、测试Redis</p>
<pre class="wp-code-highlight prettyprint">   cd src
   make test
</pre>
<p>通过以上命令就要可以对redis进行加大的测试。</p>
<p>4、配置redis<br />
（1）复制并修改配置文档<br />
代码如下:</p>
<pre class="wp-code-highlight prettyprint">cp ./redis.conf /usr/local/redis/
vi /usr/local/redis/redis.conf
</pre>
<p>我只修改了如下两项：<br />
daemonize yes #redis将以守护进程的方式运行，默认为no会暂用你的终端<br />
timeout 300​ #当 客户端闲置多长时间后关闭连接，如果指定为0，表示关闭该功能</p>
<p>（2）设置自动启动<br />
代码如下:</p>
<pre class="wp-code-highlight prettyprint">vi /etc/init.d/redis
</pre>
<p>编辑文件保存如下内容：<br />
代码如下:</p>
<pre class="wp-code-highlight prettyprint">#!/bin/sh
#
# redis        Startup script for Redis Server
#
# chkconfig: - 80 12
# description: Redis is an open source, advanced key-value store.
#
# processname: redis-server
# config: /etc/redis.conf
# pidfile: /var/run/redis.pid
source /etc/init.d/functions
BIN=&quot;/usr/local/redis/bin&quot;
CONFIG=&quot;/usr/local/redis/redis.conf&quot;
PIDFILE=&quot;/var/run/redis.pid&quot;
### Read configuration
[ -r &quot;$SYSCONFIG&quot; ] &amp;amp;&amp;amp; source &quot;$SYSCONFIG&quot;
RETVAL=0
prog=&quot;redis-server&quot;
desc=&quot;Redis Server&quot;
start() {
        if [ -e $PIDFILE ];then
             echo &quot;$desc already running....&quot;
             exit 1
        fi
        echo -n $&quot;Starting $desc: &quot;
        daemon $BIN/$prog $CONFIG
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] &amp;amp;&amp;amp; touch /var/lock/subsys/$prog
        return $RETVAL
}
stop() {
        echo -n $&quot;Stop $desc: &quot;
        killproc $prog
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] &amp;amp;&amp;amp; rm -f /var/lock/subsys/$prog $PIDFILE
        return $RETVAL
}
restart() {
        stop
        start
}
case &quot;$1&quot; in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
        restart
        ;;
  condrestart)
        [ -e /var/lock/subsys/$prog ] &amp;amp;&amp;amp; restart
        RETVAL=$?
        ;;
  status)
        status $prog
        RETVAL=$?
        ;;
   *)
        echo $&quot;Usage: $0 {start|stop|restart|condrestart|status}&quot;
        RETVAL=1
esac
exit $RETVAL
</pre>
<p>（3）启动服务和关闭<br />
/usr/local/redis/bin/redis-server<br />
如图：<a href="http://www.yunda51.com/wp-content/uploads/2015/08/20150813161557.png"><img class="alignnone size-full wp-image-1594" src="http://www.yunda51.com/wp-content/uploads/2015/08/20150813161557.png" alt="20150813161557" width="1416" height="710" /></a><br />
表示启动成功！</p>
<p><strong>启动之后最好重新打开个窗口运行redsi-cli进入控制台</strong></p>
<p>5、使用redis</p>
<pre class="wp-code-highlight prettyprint">[root@localhost /]# cd /usr/local/redis/bin/
[root@localhost bin]# redis-cli 
127.0.0.1:6379&amp;gt; set foo ceshi
OK
127.0.0.1:6379&amp;gt; get foo
&quot;ceshi&quot;
127.0.0.1:6379&amp;gt; 
</pre>
<p>如图：<a href="http://www.yunda51.com/wp-content/uploads/2015/08/redis.png"><img class="alignnone size-full wp-image-1595" src="http://www.yunda51.com/wp-content/uploads/2015/08/redis.png" alt="redis" width="1023" height="194" /></a></p>
<p>6、停止redis实例：<br />
/usr/local/redis/bin/rdis-cli shutdown 或者 pkill redis-server</p>
<p>到此为止你的redis完成，下面我们来添加phpredis安装和配置~~</p>
<p><strong>phpredis安装和配置步骤如下：</strong><br />
1、首先下载phpredis包 <a style="background: transparent none repeat scroll 0% 0%;" href="http://pan.baidu.com/s/1sjoSdLN" target=""><img class="alignnone size-full wp-image-1075" title="btn_load" src="http://www.yunda51.com/wp-content/uploads/2013/11/btn_load3.png" alt="" width="86" height="28" /></a><br />
2、解压：unzip phpredis-develop.zip<br />
3、cd phpredis-develop<br />
4、执行 /usr/local/php5/bin/phpize 会在phpredis-develop目录下生成一个configure<br />
5、./configure --with-php-config=/usr/local/php5/bin/php-config<br />
6、make<br />
7、make install<br />
如图：<a href="http://www.yunda51.com/wp-content/uploads/2015/08/redis1919.png"><img class="alignnone size-full wp-image-1600" src="http://www.yunda51.com/wp-content/uploads/2015/08/redis1919.png" alt="redis1919" width="894" height="66" /></a><br />
8、执行 cd /usr/local/php5/lib/php/extensions/no-debug-non-zts-20100525/ 目录下会有redis.so<br />
如图：<a href="http://www.yunda51.com/wp-content/uploads/2015/08/redis-so.png"><img class="alignnone size-full wp-image-1601" src="http://www.yunda51.com/wp-content/uploads/2015/08/redis-so.png" alt="redis-so" width="894" height="117" /></a><br />
9、vi /usr/local/php5/etc/php.ini 在php.ini添加redis.so扩展<br />
如图：<a href="http://www.yunda51.com/wp-content/uploads/2015/08/redis6.png"><img class="alignnone size-full wp-image-1602" src="http://www.yunda51.com/wp-content/uploads/2015/08/redis6.png" alt="redis6" width="279" height="78" /></a><br />
10、/etc/init.d/nginx restart 重启nginx（注：如果你们是Apache，也一样重启）。<br />
最后结果如图：<br />
<a href="http://www.yunda51.com/wp-content/uploads/2015/08/redis-success.png"><img class="alignnone size-full wp-image-1603" src="http://www.yunda51.com/wp-content/uploads/2015/08/redis-success.png" alt="redis-success" width="711" height="240" /></a><br />
这样就大功告成了，开启你得redis之旅吧，骚年~~~</p>
<p>转载请注明转自:<a href="http://www.yunda51.com">运达's blog</a> 原文地址：<a href="http://www.yunda51.com/1470.html">http://www.yunda51.com/1593.html</a></p>
]]></content:encoded>
			<wfw:commentRss>https://www.yunda51.com/?feed=rss2&#038;p=1593</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
