【环境配置记录】懒人 Ubuntu 2016.04 64bit 安装LNMP+Redis

来源:互联网 发布:网络课程尔雅官网 编辑:程序博客网 时间:2024/06/01 08:53

为了省事省力,快速安装好环境,找个一键安装脚本,就行了。

我找的是lnmp.org的安装包,下载好,按说明操作,选择Mysql PHP Nginx 版本,然后睡个午觉,安装好了。

安装好lnmp,设置php.ini 开启error。再一键安装 redis,选稳定版。

整个流程大概1小时吧。

需要注意的:

若使用它的lnmp vhost add 添加nginx配置,那么会在web根目录生成系统保护的.user.ini配置文件限制php目录访问,但它这样默认的配置不太适合开发,所以要用chattr -i .user.ini 命令撤销系统保护,然后修改.user.ini或者干脆删掉它。

截个图:





测试Redis:

<?php//连接 Redis$redis = new Redis();$redis->connect('127.0.0.1', 6379);echo "Connection to server sucessfully\n";//存储字符串$redis->set("tutorial-name", "Redis tutorial");$redis->expire('tutorial-name',3);//3秒过期//输出字符串echo "Stored string in redis:: " . $redis->get("tutorial-name");sleep(3);echo "\n";echo "Stored string in redis:: " . $redis->get("tutorial-name");echo "\n";//存储数据到List$redis->lpush("tutorial-list", "Redis");$redis->lpush("tutorial-list", "Mongodb");$redis->lpush("tutorial-list", "Mysql");//输出List数据$arList = $redis->lrange("tutorial-list", 0 ,5);echo "Stored string in redis\n";print_r($arList);//获取Keys$arList = $redis->keys("*");echo "Stored keys in redis:: ";print_r($arList);?>

输出结果:

Connection to server sucessfullyStored string in redis:: Redis tutorialStored string in redis::Stored string in redisArray(    [0] => Mysql    [1] => Mongodb    [2] => Redis)Stored keys in redis:: Array(    [0] => tutorial-list)
^_^


0 0
原创粉丝点击