博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LNMP环境下安装Redis,以及php的redis扩展
阅读量:4610 次
发布时间:2019-06-09

本文共 3568 字,大约阅读时间需要 11 分钟。

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 redissudo makesudo make testsudo make install

有可能会出现

You need tcl 8.5 or newer

那就去安装

sudo wget https://downloads.sourceforge.net/tcl/tcl8.6.8-src.tar.gzsudo 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-server27904: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-cli127.0.0.1:6379> set name jackOK127.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 phpizephpize: /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 redisredis

已经添加成功了!

进一步测试,

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

转载于:https://www.cnblogs.com/zmdComeOn/p/9596799.html

你可能感兴趣的文章
extern
查看>>
Bluetooth 报文知识点
查看>>
Json语法浅析
查看>>
shell脚本批量生成配置文件
查看>>
dedecms常用标签
查看>>
Underscore.js 1.3.3 中文解释
查看>>
Windows Search Service
查看>>
创建常量、原子性的值类型
查看>>
Linux常用命令
查看>>
[Bug]2016-02
查看>>
菜鸟也想玩搜索引擎——JobSearch简介
查看>>
Java 集合系列之二:List基本操作
查看>>
Java的内存泄漏
查看>>
Python
查看>>
(五)Qt实现自定义模型基于QAbstractItemModel
查看>>
编程题练习
查看>>
mac os安装vim74
查看>>
Linux内存管理原理
查看>>
Java 8 Lambda 表达式
查看>>
BZOJ-3289 Mato的文件管理
查看>>