sudo wget http://download.redis.io/releases/redis-④0.9.tar.gz
sudo tar zvxf redis-4.0.9.tar.gz
sudo mv redis-④0.9/ redis
cd redis
sudo make
sudo make test
sudo make install
有可能会出现
You need tcl ⑧5 or newer
那就去安装
sudo wget https://downloads.sourceforge.net/tcl/tcl⑧⑥8-src.tar.gz
sudo tar xzvf tcl8.6.8-src.tar.gz -C /usr/local/
cd /usr/local/tcl⑧⑥1/unix/
sudo ./configure
sudo make
sudo make install
成功了
redis-server
27904:C 23 May 02:23:52.443 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
27904:C 23 May 02:23:52.443 # Redis version=④0.9, bits=64, commit=00000000, modified=0, pid=27904, just started
27904:C 23 May 02:23:52.443 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
27904:M 23 May 02:23:52.445 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
27904:M 23 May 02:23:52.445 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
27904:M 23 May 02:23:52.445 # Current maximum open files is 409⑥ maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_.-++__ ''-._
_.-++ +. +_. ''-._ Redis ④0.9 (00000000/0) 64 bit
.-++ .-+++. +++\/ _.,_ ''-._
( ' , .-+ | +, ) Running in standalone mode
|+-._+-...-+ __...-.++-._|'+ _.-'| Port: 6379
| +-._ +._ / _.-' | PID: 27904
+-._ +-._ +-./ _.-' _.-'
|+-._+-._ +-.__.-' _.-'_.-'|
| +-._+-._ _.-'_.-' | http://redis.io
+-._ +-._+-.__.-'_.-' _.-'
|+-._+-._ +-.__.-' _.-'_.-'|
| +-._+-._ _.-'_.-' |
+-._ +-._+-.__.-'_.-' _.-'
+-._ +-.__.-' _.-'
+-._ _.-'
+-.__.-'
jiqing@jiqing-pad:~$ redis-cli
12⑦0.0.1:6379> set name jack
OK
12⑦0.0.1:6379> get name
"jack"
12⑦0.0.1:6379>
如果出现
A.找到redis.conf 并修改 daemonize no 为 daemonize?yes?,这样就可以默认启动就后台运行
vi /etc/redis.conf
redis-server /etc/redis.conf
安装PHP-redis扩展
sudo wget https://pecl.php.net/get/redis-④0.2.tgz
sudo tar -zxvf redis-4.0.2.tgz
$whereis phpize
phpize: /usr/bin/phpize
sudo /usr/bin/phpize
drwxr-xr-x 2 root root 4096 5月 23 01:57 ./
drwxr-xr-x 10 root root 4096 5月 23 01:57 ../
-rwxr-xr-x 1 root root 837 5月 23 01:57 pear*
-rwxr-xr-x 1 root root 858 5月 23 01:57 peardev*
-rwxr-xr-x 1 root root 774 5月 23 01:57 pecl*
lrwxrwxrwx 1 root root 9 5月 23 01:57 phar -> phar.phar*
-rwxr-xr-x 1 root root 14833 5月 23 01:57 phar.phar*
-rwxr-xr-x 1 root root 48618304 5月 23 01:57 php*
-rwxr-xr-x 1 root root 48473272 5月 23 01:57 php-cgi*
-rwxr-xr-x 1 root root 3325 5月 23 01:57 php-config*
-rwxr-xr-x 1 root root 4534 5月 23 01:57 phpize*
sudo ./configure --with-php-config=/usr/local/php/bin/php-config
sudo make
sudo make test
这个时候会报一些错误,打开php.ini
sudo vi /usr/local/php/etc/php.ini
disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
去除shell_exec,proc_open
sudo make install
extension=redis.so
查看
php -m
jiqing@jiqing-pad:/$ php -m |grep redis
redis
已经添加成功了!
进一步测试,
new Redis();
$redis->connect('12⑦0.0.1',6379);
$redis->set('test','hello world!');
echo $redis->get('test');
?>
hello world!
Process finished with exit code 0
成功!
进一步查看服务开启情况!
jiqing@jiqing-pad:/home/wwwroot/default$ sudo netstat -anp|grep :6379
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 27904/redis-server
tcp6 0 0 :::6379 :::* LISTEN 27904/redis-server
jiqing@jiqing-pad:/home/wwwroot/default$ sudo ps -ef |grep redis
jiqing 1576 32272 0 03:05 pts/1 00:00:00 grep --color=auto redis
jiqing 27904 1772 0 02:23 ? 00:00:02 redis-server *:6379
sudo wget http://download.redis.io/releases/redis-④0.9.tar.gz
sudo tar zvxf redis-4.0.9.tar.gz
sudo mv redis-④0.9/ redis
cd redis
sudo make
sudo make test
sudo make install
You need tcl ⑧5 or newer
sudo wget https://downloads.sourceforge.net/tcl/tcl⑧⑥8-src.tar.gz
sudo tar xzvf tcl8.6.8-src.tar.gz -C /usr/local/
cd /usr/local/tcl⑧⑥1/unix/
sudo ./configure
sudo make
sudo make install
redis-server
27904:C 23 May 02:23:52.443 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
27904:C 23 May 02:23:52.443 # Redis version=④0.9, bits=64, commit=00000000, modified=0, pid=27904, just started
27904:C 23 May 02:23:52.443 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
27904:M 23 May 02:23:52.445 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
27904:M 23 May 02:23:52.445 # Server can't set maximum open files to 10032 because of OS error: Operation not permitted.
27904:M 23 May 02:23:52.445 # Current maximum open files is 409⑥ maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_.-++__ ''-._
_.-++ +. +_. ''-._ Redis ④0.9 (00000000/0) 64 bit
.-++ .-+++. +++\/ _.,_ ''-._
( ' , .-+ | +, ) Running in standalone mode
|+-._+-...-+ __...-.++-._|'+ _.-'| Port: 6379
| +-._ +._ / _.-' | PID: 27904
+-._ +-._ +-./ _.-' _.-'
|+-._+-._ +-.__.-' _.-'_.-'|
| +-._+-._ _.-'_.-' | http://redis.io
+-._ +-._+-.__.-'_.-' _.-'
|+-._+-._ +-.__.-' _.-'_.-'|
| +-._+-._ _.-'_.-' |
+-._ +-._+-.__.-'_.-' _.-'
+-._ +-.__.-' _.-'
+-._ _.-'
+-.__.-'
jiqing@jiqing-pad:~$ redis-cli
12⑦0.0.1:6379> set name jack
OK
12⑦0.0.1:6379> get name
"jack"
12⑦0.0.1:6379>
sudo wget https://pecl.php.net/get/redis-④0.2.tgz
sudo tar -zxvf redis-4.0.2.tgz
$whereis phpize
phpize: /usr/bin/phpize
sudo /usr/bin/phpize
drwxr-xr-x 2 root root 4096 5月 23 01:57 ./
drwxr-xr-x 10 root root 4096 5月 23 01:57 ../
-rwxr-xr-x 1 root root 837 5月 23 01:57 pear*
-rwxr-xr-x 1 root root 858 5月 23 01:57 peardev*
-rwxr-xr-x 1 root root 774 5月 23 01:57 pecl*
lrwxrwxrwx 1 root root 9 5月 23 01:57 phar -> phar.phar*
-rwxr-xr-x 1 root root 14833 5月 23 01:57 phar.phar*
-rwxr-xr-x 1 root root 48618304 5月 23 01:57 php*
-rwxr-xr-x 1 root root 48473272 5月 23 01:57 php-cgi*
-rwxr-xr-x 1 root root 3325 5月 23 01:57 php-config*
-rwxr-xr-x 1 root root 4534 5月 23 01:57 phpize*
sudo ./configure --with-php-config=/usr/local/php/bin/php-config
sudo make
sudo make test
sudo vi /usr/local/php/etc/php.ini
disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
sudo make install
extension=redis.so
php -m
jiqing@jiqing-pad:/$ php -m |grep redis
redis
new Redis();
$redis->connect('12⑦0.0.1',6379);
$redis->set('test','hello world!');
echo $redis->get('test');
?>
hello world!
Process finished with exit code 0
jiqing@jiqing-pad:/home/wwwroot/default$ sudo netstat -anp|grep :6379
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 27904/redis-server
tcp6 0 0 :::6379 :::* LISTEN 27904/redis-server
jiqing@jiqing-pad:/home/wwwroot/default$ sudo ps -ef |grep redis
jiqing 1576 32272 0 03:05 pts/1 00:00:00 grep --color=auto redis
jiqing 27904 1772 0 02:23 ? 00:00:02 redis-server *:6379
以上就是土嘎嘎小编为大家整理的LNMP环境下安装Redis,以及php的redis扩展相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!