1.下载

sudo wget http://download.redis.io/releases/redis-4.0.9.tar.gz

2.解压

sudo tar zvxf redis-4.0.9.tar.gz

3.重命名

sudo mv redis-4.0.9/ redis

4.编译

cd redis
sudo make
sudo make test
sudo make install

有可能会出现

You need tcl 8.5 or newer

那就去安装

sudo wget https://downloads.sourceforge.net/tcl/tcl8.6.8-src.tar.gz
sudo tar xzvf tcl8.6.8-src.tar.gz -C /usr/local/
cd /usr/local/tcl8.6.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=4.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 4096. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 4.0.9 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 27904
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
jiqing@jiqing-pad:~$ redis-cli
127.0.0.1:6379> set name jack
OK
127.0.0.1:6379> get name
"jack"
127.0.0.1:6379>

安装PHP-redis扩展

1.下载

sudo wget https://pecl.php.net/get/redis-4.0.2.tgz

2.解压

sudo tar -zxvf redis-4.0.2.tgz

3.找到phpize文件,生成配置

$whereis phpize
phpize: /usr/bin/phpize

在redis-4.0.2文件夹中执行

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*

4.配置

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

5.添加扩展

extension=redis.so

查看

php -m
jiqing@jiqing-pad:/$ php -m |grep redis
redis

已经添加成功了!

进一步测试,

<?php
$redis = new Redis();
$redis->connect('127.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

ubuntu LNMP环境下安装Redis,以及php的redis扩展的更多相关文章

  1. linux lnmp环境下 安装apache教程

    linux lnmp环境下 安装apache教程 源码安装 apr ,apr-util 安装apache要用<pre>wget http://mirrors.cnnic.cn/apache ...

  2. lnmp环境里安装mssql及mssql的php扩展

    小活中用到mssql,于是在自己lnmp环境中安装各mssql数据库 步骤如下: 源码编译安装 (1)下载freetds-stable-0.91源码:http://download.csdn.net/ ...

  3. LNMP环境下安装Redis,以及php的redis扩展

    1.下载 sudo wget http://download.redis.io/releases/redis-4.0.9.tar.gz 2.解压 sudo tar zvxf redis-4.0.9.t ...

  4. 在centos6.7中lnmp环境下安装swoole插件和pthreads插件

    1.首先在安装lnmp集成包之前,解压lnmp1.3-full.tar.gz,进入到lnmp1.3-full/include/目录下; 2.输入 vi php.sh;编辑php.sh文档.博主安的是p ...

  5. linux(ubuntu)环境下安装IDEA

    想调试java虚拟机内存溢出的情况,在调试过程中总会出现一些不可预见的状况,正好在学linux,在windows上安装了虚拟机,安装的镜像是ubuntu(乌班图)装在了虚拟机中,装在虚拟机中好处是即使 ...

  6. linux(ubuntu)环境下安装及配置JDK

    安装完IDEA之后遇到了问题,发现jdk安装完之后配置环境变量好困难,下面总结一下我的安装及配置方式: JDK下载链接:http://download.oracle.com/otn-pub/java/ ...

  7. Ubuntu Anaconda3 环境下安装caffe

    安装Python环境 本人环境为Anaconda3 ,可参照 https://blog.csdn.net/ctwy291314/article/details/86571198 完成安装Python2 ...

  8. ubuntu linux环境下安装配置jdk和tomcat

    关于linux搭建服务器,ubuntu中jdk和tomcat的安装和配置 一.jdk的安装配置 1:去官网下载好自己需要的版本,注意,linux压缩文件通常以tar.gz结尾,别下载错了.本次我下载安 ...

  9. Ubuntu --- lamp环境下安装php扩展和开启apache重写

    安装教程参考:http://www.laozuo.org/8303.html 1.安装php扩展(比如安装mbstring) 先搜索相关的包 apt-cache search php7 再安装 apt ...

随机推荐

  1. Git上传的使用步骤

    Git上传的使用步骤 首先 git branch 查看当前的分支是否为本地自己分支 接着 git stash 保存本地自己的保存 git checkout earemote 查看本地共有开发分支 gi ...

  2. zoj 2835 Magic Square(set)

    Magic Square Time Limit: 2 Seconds      Memory Limit: 65536 KB In recreational mathematics, a magic ...

  3. 【ITOO 2】.NET 动态建库建表:使用SQL字符串拼接方式

    导读:在最近接手的项目(高效云平台)中,有一个需求是要当企业用户注册时,给其动态的新建一个库和表.刚开始接手的时候,是一点头绪都没有,然后查了一些资料,也问了问上一版本的师哥师姐,终于有了点头绪.目前 ...

  4. hdu 3879 最大权闭合图(裸题)

    /* 裸的最大权闭合图 解:参见胡波涛的<最小割模型在信息学竞赛中的应用 #include<stdio.h> #include<string.h> #include< ...

  5. 栈 练习 Codevs 3137 3138 3139

    3137 栈练习1 时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题目描述 Description 给定一个栈(初始为空,元素类型为整数,且小于等于100),只 ...

  6. C#中的各种排序算法

    原文发布时间为:2008-11-26 -- 来源于本人的百度文章 [由搬家工具导入] C#算法(一)选择排序using System;public class SelectionSorter{    ...

  7. ASP.NET状态保持cookie与session

    ASP.Net状态保持 一.ASP.Net中的状态保持如下图:   二.客户端的状态保持方案     ViewState.隐藏域.Cookies.控件状态.URL查询参数      ->View ...

  8. Codeforces 653D Delivery Bears【二分+网络流】

    题目链接: http://codeforces.com/problemset/problem/653/D 题意: x个熊拿着相同重量的物品,从1号结点沿着路走到N号结点,结点之间有边相连,保证可以从1 ...

  9. hdu 4971

    记忆花搜索   dp #include <cstdio> #include <cstdlib> #include <cmath> #include <set& ...

  10. flash update

    https://get.adobe.com/cn/flashplayer/otherversions/