1, reference article "installation 3.0.3 version Configuration article reference"
Http://www.iyunv.com/thread-89612-1-1.html
2. Install TCL package (requires TCL support to install Redis)
Download: http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
Upload tcl8.6.1-src.tar.gz to/usr/local/src directory
CD/USR/LOCAL/SRC #进入软件包存放目录
Tar zxvf tcl8.6.1-src.tar.gz #解压
CD tcl8.6.1 #进入安装目录
CD UNIX
./configure--prefix=/usr--without-tzdata--mandir=/usr/share/man $ ([$ (uname-m) = x86_64] && echo--enable-64b IT) #配置
Make #编译
Sed-e "[Email protected]^\ (tcl_src_dir= '). *@\1/usr/include ' @"-e "/tcl_b/[email protected]= ' \ (-l\) \?. *unix@= ' \1/usr/[email protected] "-I tclconfig.sh
Make install #安装
Make Install-private-headers
Ln-v-SF Tclsh8.6/usr/bin/tclsh
Chmod-v 755/usr/lib/libtcl8.6.so
3. Compiling and installing Redis
Download: http://download.redis.io/redis-stable.tar.gz (Download 3.0.3 version)
Upload redis-stable to/usr/local/src directory
Cd/usr/local/src
TAR-ZXVF redis-stable.tar.gz #解压
MV Redis-stable/usr/local/redis #移动文件到安装目录
Cd/usr/local/redis #进入安装目录
Make #编译
Make install #安装
redis-* all binaries will be copied to/usr/local/bin (only Redis-server and redis-cli are used for beginners)
4. Test whether the installation is normal
Start Redis-server
Start another SSH form, start redis-cli, enter set foo bar, and then enter get foo, if you can echo "bar" correctly, the installation succeeds
5. Modify the redis.conf in the source code of the installation package
Change Daemonize one item to Yes
According to the actual situation, change port to the desired port number (redis-cli-h connected ip-p the correct port on the next connection)
Copy the redis.conf to the specified directory, such as/path/to/redis/redis.conf
Modify the Dbfilename (dump-out database) and Dir (the dump-out database directory) according to your actual needs
MaxClients Maximum number of client connections, 0 is unrestricted; maxmemory Maximum available memory
Appendfsync Write Disk Policy always|everysec|no
Databases database number, you can use select dbid to select the database to write to, dbid range is 0 to databases-1
MaxMemory maximum available memory, with Maxmemory-policy (strategy to reach maximum memory) and Maxmemory-samples (LRU estimation sample, 3 fast but imprecise, 10 Max close to Real, default 5)
6. Test again
Redis-server/path/to/redis/redis.conf
Redis-cli-p the correct port
7. After the test is normal, set the startup script to name the startup script Redis:
Modify the values of the Progdir and config two variables as practical, then run to see if they are normal
#!/bin/sh
#chkconfig: 2345 86 14
#description: Startup and shutdown script for Redis
Progdir=/usr/local/bin
Progname=redis-server
daemon= $PROGDIR/$PROGNAME
Config=/alidata/server/redis/redis.conf
Pidfile=/var/run/redis.pid
desc= "Redis Daemon"
Scriptname=/etc/rc.d/init.d/redis
Start ()
{
If Test-x $DAEMON
Then
Echo-e "Starting $DESC: $PROGNAME"
If $DAEMON $CONFIG
Then
Echo-e "OK"
Else
Echo-e "Failed"
Fi
Else
Echo-e "couldn ' t find Redis Server ($DAEMON)"
Fi
}
Stop ()
{
If Test-e $PIDFILE
Then
Echo-e "Stopping $DESC: $PROGNAME"
If kill ' cat $PIDFILE '
Then
Echo-e "OK"
Else
Echo-e "Failed"
Fi
Else
Echo-e "No Redis Server ($DAEMON) Running"
Fi
}
Restart ()
{
Echo-e "Restarting $DESC: $PROGNAME"
Stop
Start
}
List ()
{
PS aux | grep $PROGNAME
}
Case $ in
Start
Start
;;
Stop
Stop
;;
Restart
Restart
;;
List
List
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|list}" >&2
Exit 1
;;
Esac
Exit 0
8. Copy the startup script Redis to/etc/rc.d/init.d/
Add Service chkconfig--add Redis
Set boot Chkconfig--level 2345 Redis on
9. Start Service Redis start
Turn off service Redis stop
Restart Service Redis Restart
10. Installing the Redis Extension
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config
Make
Make install
#执行完make Install will generate
#Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
#修改php. ini
#添加redis
Extension = redis.so
11. Connect to Redis database via PHP program
Redis Database ip:192.168.21.128
Port: 6379
Password: 123456
Test code:
<?php
$redis = new Redis ();
$redis->connect (' 192.168.21.128 ', 6379);
$redis->auth (' 123456 ');
$redis->select (1);
$ret = $redis->set (' www.osyunwei.com ', ' Osyunwei ');
Var_dump ($ret);
$allKeys = $redis->keys (' * ');
Print_r ($allKeys);
?>
Save the above code as test.php, and the following page will appear after opening
BOOL (TRUE) Array ([0] = www.osyunwei.com)
At this point, the Redis Server installation configuration for Linux is complete.
All of the above resources are available for download at (Http://url.cn/YWJatC)
Install Redis error-free process