OpenResty 安装

  1. 首先去OpenResty中文官网 http://openresty.org/cn/

2.然后添加 环境到Path

安装就这么多OK

运行一个Hello World

  1. 在任意一个地方新建一个文件夹(注意最好不要有中文路径)

例如在桌面 新建一个 example 文件夹, 目录结构如下 (目录树生成网站 http://dir.yardtea.cc/)

example
└─ hello
       ├─ conf
       │    └─ nginx.conf
       ├─ data
       │    └─ html
       │           └─ kbn.html
       └─ logs
            ├─ access.log
            ├─ error.log
            └─ nginx.pid
  1. 其中 logs 和conf 必要的, 里面的文件自己可以新建一个空文件

  2. 打开nginx.conf 如一配置

worker_processes  1;
error_log logs/error.log;
events {
    worker_connections 1024;
}
http {
    server {
        listen 9000;
        default_type text/html;
        location / {
            root /data/html;
            index kbn.html;
        }
    }
}
  1. 启动 nginx
    • nginx -p 你的文件夹 -c conf/nginx.conf
    • 或 cd到你的 hello 使用 nginx -c conf/nginx.conf

    如果启动 报错 resty.core 找不到, 就把nginx安装目录中的 lua,luaLib 两个文件夹复制到你的project 里面去

  2. 当你修改你的配置之后 使用 nginx -s reload
  3. 停止 nginx nginx -s stop

conterOS 安装 OpenResty

官方说明:OpenResty® 是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项。用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关。

下载地址:

  1. 安装依赖库:
$ yum install -y pcre-devel openssl-devel gcc curl
  1. 下载OpenResty版本:
$ wget https://openresty.org/download/openresty-1.15.8.1.tar.gz
  1. 解压:
$ tar -xzvf openresty-1.15.8.1.tar.gz
  1. 进入解压目录:
$ cd openresty-1.15.8.1/
  1. 检查配置环境, 生成 Makefile,默认安装到/usr/local/openresty:
$ ./configure
  1. 编译安装:
$ gmake && gmake install

安装结果:

mkdir -p /usr/local/openresty/site/lualib /usr/local/openresty/site/pod /usr/local/openresty/site/manifest
ln -sf /usr/local/openresty/nginx/sbin/nginx /usr/local/openresty/bin/openresty

可以看到openresty 实际上是nginx的软连接。

  1. 查看版本号:
$ /usr/local/openresty/bin/openresty -v
nginx version: openresty/1.15.8.3
  1. 启动:
检验配置
/usr/local/openresty/bin/openresty -t
启动
/usr/local/openresty/bin/openresty
停止
/usr/local/openresty/bin/openresty -s stop
重新加载配置
/usr/local/openresty/bin/openresty -s reload
  1. 配置/lib/systemd/system/openresty.service,通过systemctl启动:
[Unit]
Description=openresty - high performance web server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/openresty/bin/openresty -c /usr/local/openresty/nginx/conf/nginx.conf
ExecReload=/usr/local/openresty/bin/openresty -s reload
ExecStop=/usr/local/openresty/bin/openresty -s stop

[Install]
WantedBy=multi-user.target

添加openresty.service后,使配置文件生效:

$ systemctl daemon-reload

然后,就可以使用systemctl管理openresty:

启动
$ systemctl start openresty
停止
$ systemctl stop openresty
重载配置
$ systemctl reload openresty
重启
$ systemctl restart openresty

版权声明:本文为CSDN博主「depakin」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/yisangwu/article/details/106728595

也可以参考这里 https://my.oschina.net/u/4305985/blog/3663887


Ubuntu OpenResty 安装的过程

先去官网 http://openresty.org/en/installation.html
先决条件 你应该有perl 5.6.1+,libpcre,libssl

apt-get install libpcre3-dev libssl-dev perl make build-essential curl

然后要安装 zlib 参考 https://blog.csdn.net/weixin_43944305/article/details/108219746

wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar -xzvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install

再安装 openResty

wget https://openresty.org/download/openresty-1.19.9.1.tar.gz
tar -xvf openresty-1.19.9.1.tar.gz
cd openresty-1.19.9.1/
./configure -j2
make -j2
sudo make install

better also add the following line to your ~/.bashrc or ~/.bash_profile file.
export PATH=/usr/local/openresty/bin:$PATH

LuaRocks 安装

$ wget https://luarocks.org/releases/luarocks-3.7.0.tar.gz
$ tar zxpf luarocks-3.7.0.tar.gz
$ cd luarocks-3.7.0
$ ./configure && make && sudo make install
$ sudo luarocks install luasocket
$ lua
Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio
> require "socket"

如果是 5.1

$ ./configure --lua-version=5.1  --versioned-rocks-dir
$ make build
$ sudo make install
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,657评论 6 505
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,889评论 3 394
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,057评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,509评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,562评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,443评论 1 302
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,251评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,129评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,561评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,779评论 3 335
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,902评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,621评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,220评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,838评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,971评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,025评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,843评论 2 354

推荐阅读更多精彩内容