1.lnmp 搭建nginx+mysql+php
分别nginx,mysql,php -v查询版本,正确没问题
2.启动nginx,直接输入 nginx即可,
配置nginx,输入nginx -t查询config路径,在/usr/local/nginx/conf/nginx.conf ,修改上传,一定要在xshell里面nginx -s reload重新加载
nginx -s reopen
nginx -s stop
关键网页路径访问位置
3.可以另起一个端口,root路径改一下,经过改动的路径需要chmod 777 -R /***/** 设置可读写
4.把onethink放入第3步路径底下。
5.安装node+npm+forever http://www.cnblogs.com/hamhog/p/3574582.html
如下 apt-get 改为 yum运行
1. 安装node
apt-get install nodejs
2. 安装npm
apt-get update
apt-get install npm
3. 安装forever
此时安装forever失败。提示:
npm ERR! Error: failed to fetch from registry:
执行:
npm config set registry http://registry.npmjs.org
如果被墙,可以设置如下:npm config set registry https://registry.npm.taobao.org
安装forever仍然失败。提示:
/usr/local/lib/node_modules/forever/node_modules/microtime/wscript:9: error: could not configure a cxx compiler!
于是安装g++:
最后安装forever:
npm install forever -g
如果一直卡住不动,说明被墙,看这个帖子:http://blog.csdn.net/qq591840685/article/details/53385365
这里等的要久一些,耐心一下
4. 启动node
进入node所在目录,然后执行(以server.js为例):
forever start server.js
1.lnmp搭建redis缓存数据库
eAccelerator、xcache、memcached、imageMagick、ionCube、redis、opcache的安装
https://lnmp.org/faq/addons.html
此脚本是用来安装Redis,Redis是一个开源、支持网络、基于内存、键值对存储数据库。
1------安装
进入lnmp解压后的目录,执行:./addons.sh install redis
运行后有如下提示:
,安装稳定版Redis 2.8.8 输入:s 回车;安装测试版Redis 3.0.0输入:b 回车;安装旧版Redis 2.6.17输入:o 回车。
2----安装phpredis驱动
http://www.runoob.com/redis/redis-php.html
PHP 使用 Redis
安装
开始在 PHP 中使用 Redis 前, 我们需要确保已经安装了 redis 服务及 PHP redis 驱动,且你的机器上能正常使用 PHP。 接下来让我们安装 PHP redis 驱动:下载地址为:https://github.com/phpredis/phpredis/releases。
PHP安装redis扩展
以下操作需要在下载的 phpredis 目录中完成:
$ wget https://github.com/phpredis/phpredis/archive/2.2.4.tar.gz
://github.com/phpredis/phpredis/archive/2.2.4.tar.gz
tar -xzvf 2.2.4.tar.gz
$ cd phpredis-2.2.4 # 进入 phpredis 目录
$ /usr/local/php/bin/phpize # php安装后的路径
$ ./configure --with-php-config=/usr/local/php/bin/php-config
$ make && make install
-2.2.4 # 进入 phpredis 目录
$ /usr/local/php/bin/phpize # php安装后的路径
$ ./configure --with-php-config=/usr/local/php/bin/php-config
$ make && make install
如果你是 PHP7 版本,则需要下载指定分支:
git clone -b php7 https://github.com/phpredis/phpredis.git
-b php7 https://github.com/phpredis/phpredis.git
修改php.ini文件
vi /usr/local/php/lib/php.ini
/usr/local/php/lib/php.ini
注意:***** 这个目录不一定准确,/usr/local/php/etc/php.ini也可能。
增加如下内容:
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20090626"
extension=redis.so
= "/usr/local/php/lib/php/extensions/no-debug-zts-20090626"
extension=redis.so
注意:*****no-debug-zts-20090626 这个字符串需要更换掉,你自己该目录里面的文件夹的名字。
安装完成后重启php-fpm 或 apache。重启LNMP,1.2+输入命令:lnmp restart 即可;单独重启mysql:/etc/init.d/mysql restart 也可以 lnmp mysql restart
查看phpinfo信息,就能看到redis扩展。
连接到 redis 服务
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//查看服务是否运行
echo "Server is running: " . $redis->ping();
?>
php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//查看服务是否运行
echo "Server is running: " . $redis->ping();
?>
执行脚本,输出结果为:
Connection to server sucessfully
Server is running: PONG
to server sucessfully
Server is running: PONG
Redis PHP String(字符串) 实例
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//设置 redis 字符串数据
$redis->set("tutorial-name", "Redis tutorial");
// 获取存储的数据并输出
echo "Stored string in redis:: " . $redis->get("tutorial-name");
?>
php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//设置 redis 字符串数据
$redis->set("tutorial-name", "Redis tutorial");
// 获取存储的数据并输出
echo "Stored string in redis:: " . $redis->get("tutorial-name");
?>
执行脚本,输出结果为:
Connection to server sucessfully
Stored string in redis:: Redis tutorial
to server sucessfully
Stored string in redis:: Redis tutorial
Redis PHP List(列表) 实例
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//存储数据到列表中
$redis->lpush("tutorial-list", "Redis");
$redis->lpush("tutorial-list", "Mongodb");
$redis->lpush("tutorial-list", "Mysql");
// 获取存储的数据并输出
$arList = $redis->lrange("tutorial-list", 0 ,5);
echo "Stored string in redis";
print_r($arList);
?>
php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
//存储数据到列表中
$redis->lpush("tutorial-list", "Redis");
$redis->lpush("tutorial-list", "Mongodb");
$redis->lpush("tutorial-list", "Mysql");
// 获取存储的数据并输出
$arList = $redis->lrange("tutorial-list", 0 ,5);
echo "Stored string in redis";
print_r($arList);
?>
执行脚本,输出结果为:
Connection to server sucessfully
Stored string in redis
Redis
Mongodb
Mysql
to server sucessfully
Stored string in redis
Redis
Mongodb
Mysql
Redis PHP Keys 实例
<?php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
// 获取数据并输出
$arList = $redis->keys("*");
echo "Stored keys in redis:: ";
print_r($arList);
?>
php
//连接本地的 Redis 服务
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo "Connection to server sucessfully";
// 获取数据并输出
$arList = $redis->keys("*");
echo "Stored keys in redis:: ";
print_r($arList);
?>
执行脚本,输出结果为:
Connection to server sucessfully
Stored string in redis::
tutorial-name
tutorial-list
to server sucessfully
Stored string in redis::
tutorial-name
tutorial-list
oneThink里面用到redis方法:$redis = new \Redis(); 斜杠不能少
今天尝试编译内核,下载到了一份tar.xz结尾的压缩文件,网上解决方法比较少,不过还是找到了,如下
补充:目前可以直接使用 tar xvJf ***.tar.xz来解压
tar.gz 文件:tar zxvf 文件.tar.gz
yum安装:
# yum install 包名
yum卸载:
# yum -y remove 包名
在Linux系统安装Nodejs 最简单步骤
1、去官网下载和自己系统匹配的文件:
英文网址:https://nodejs.org/en/download/
中文网址:http://nodejs.cn/download/
通过 uname -a 命令查看到我的Linux系统位数是64位(备注:x86_64表示64位系统, i686 i386表示32位系统),如图
故下载一下红色框中文件 ,版本为v6.10.0
2、下载下来的tar文件上传到服务器并且解压,然后通过建立软连接变为全局;
1)上传服务器可以是自己任意路径,目前我的放置路径为 cd /app/software/
2)解压上传(解压后的文件我这边将名字改为了nodejs,这个地方自己随意,只要在建立软连接的时候写正确就可以)
① tar -xvf node-v6.10.0-linux-x64.tar.xz
② mv node-v6.10.0-linux-x64 nodejs
③确认一下nodejs下bin目录是否有node 和npm文件,如果有执行软连接,如果没有重新下载执行上边步骤;
3)建立软连接,变为全局
①ln -s /app/software/nodejs/bin/npm /usr/local/bin/
②ln -s /app/software/nodejs/bin/node /usr/local/bin/
4)最后一步检验nodejs是否已变为全局
在Linux命令行node -v 命令会显示nodejs版本,如图所示为大功告成