【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
1.环境说明
ubuntu 12.04源码存储路径 /home/wzw/workstation/src
安装路径 /home/wzw/workstation/env
切换到工作目录 cd /home/wzw/workstation/src/
2.安装和运行
mkdir -p /home/wzw/workstation/env/redis
wget http://download.redis.io/releases/redis-2.6.16.tar.gz
sudo tar -zxvf redis-2.6.16.tar.gz
sudo cp -r redis-2.6.16/* /home/wzw/workstation/env/redis
cd /home/wzw/workstation/env/redis
sudo make
sudo make install
cd /usr/local/bin
sudo ./redis-server &
./redis-cli
参见下图
3.使用 Predis 连接 redis
(1) 下载 Predis,解压文件,把 解压后目录中lib下的Predis目录复制到站点根目录,附linux命令:wget https://github.com/nrk/predis/archive/v0.8.zip
unzip v0.8.zip
cd predis-0.8/
cd lib
cp -r Predis/ /home/wzw/workstation/env/nginx/html/
(2)在站点目录新建php文件,内容如下:
<?php
require "Predis/Autoloader.php";
Predis\Autoloader::register();
$redis = new Predis\Client();
$redis->set('foo', 'fuck you');
$value = $redis->get('foo');
echo "$value";
?>
(3)访问站点,见下图
来源:oschina
链接:https://my.oschina.net/u/815299/blog/163800