美文网首页
OpenResty+Lor入门开发一个HelloWorld

OpenResty+Lor入门开发一个HelloWorld

作者: 黑小马_ | 来源:发表于2019-02-28 11:26 被阅读0次

1,非常重要,OpenResty安装

openresty如下:
官网教程地址如下,其他Linux发行版参考
http://openresty.org/cn/linux-packages.html

ubuntu安装教程,copy如下:
# 导入我们的 GPG 密钥:
wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add -

# 安装 add-apt-repository 命令
# (之后你可以删除这个包以及对应的关联包)
sudo apt-get -y install software-properties-common

# 添加我们官方 official APT 仓库:
sudo add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main"

# 更新 APT 索引:
sudo apt-get update
然后就可以像下面这样安装软件包,比如 openresty:

sudo apt-get install openresty
这个包同时也推荐安装 openresty-opm 和 openresty-restydoc 包,所以后面两个包会缺省安装上。 如果你不想自动关联安装,可以用下面方法关闭自动关联安装:

sudo apt-get install --no-install-recommends openresty

检查环境安装

hxm@heixiaoma:~/openresty$ openresty -v
nginx version: openresty/1.13.6.2

2,LuaJit安装

Ubuntu: sudo apt-get install luajit
其他Linux发行版参考即可,测试结果
hxm@heixiaoma:~/openresty$ luajit -v
LuaJIT 2.0.4 -- Copyright (C) 2005-2015 Mike Pall. http://luajit.org/

3,Lor框架安装

文档地址:http://lor.sumory.com/index-cn

1.克隆下载,安装
git clone https://github.com/sumory/lor
cd lor
make install

2.运行lord -v 查询结果
hxm@heixiaoma:~/openresty/lor$ lord -v
0.3.4

3,lord命令是一个脚手架功能
   创建一个lor_hello项目
   hxm@heixiaoma:~/openresty/lor$ lord new lor_hello

4.我们开始启动这个项目吧,哈哈,简单一批啊,任重而道远
   hxm@heixiaoma:~/openresty/lor$ cd lor_hello
   hxm@heixiaoma:~/openresty/lor$ lord start
   或者sh start.sh 启动,sh stop.sh 停止
  -------------------------------------------
  由于安装的时候nginx变为了openresty,需要修改才能用, 在第4点
  
  

4注意啦,Lor里面默认是Nginx,我们需要改成openresty,或者把openresty改为nginx(*)

方式一:
start.sh脚本
stop.sh脚本
reload.sh脚本
都要改,主要是下面的那个命令

if [ -n "$1" ];then
    PROFILE="$1"
else
    PROFILE=dev
fi

mkdir -p logs & mkdir -p tmp
echo "start lor application with profile: "${PROFILE}
#主要是这个位置的openresty,改为openresty
openresty -p `pwd`/ -c conf/nginx-${PROFILE}.conf

-------------------------------------------
方式二:
不建议,方式一的操作,来看看方式二吧
hxm@heixiaoma:~/ whereis openresty
查询位置
我的在、/usr/bin/openresty
然后执行:
hxm@heixiaoma:~/ sudo mv openresty nginx
修改完毕,你可以进行上面的运行了

5运行结果

image.png

相关文章

网友评论

      本文标题:OpenResty+Lor入门开发一个HelloWorld

      本文链接:https://www.haomeiwen.com/subject/ppxhuqtx.html