美文网首页
安装OpenResty

安装OpenResty

作者: 阿畅00000 | 来源:发表于2022-09-15 18:53 被阅读0次

OpenResty(⼜称:ngx_openresty) 是⼀一个基于 NGINX 的可伸缩的 Web 平台,OpenResty 是⼀一个强⼤大的 Web 应⽤用服务器器,Web 开发⼈人员可以使⽤用 Lua 脚本语⾔言调动 Nginx ⽀支持的各种 C 以及 Lua 模块,更更主要的是在性能⽅方⾯面,OpenResty可以 快速构造出⾜足以胜任 10K 以上并发连接响应的超⾼高性能 Web 应⽤用系统。

OpenResty中⽂官网: http://openresty.org/cn/

运⾏⼀个Hello World
  1. 在任意⼀个地⽅新建⼀个⽂件夹(注意最好不要有中⽂路径)。例如:在桌面新建⼀个 example 文件夹, ⽬录结构如下 (⽬录树生成网站 http://dir.yardtea.cc/)
    image.png

2.其中logs和conf是必要的,⾥面的⽂件可以新建空文件。

  1. 打开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;
        }
} }

4.启动nginx

  • nginx -p 你的⽂文件夹 -c conf/nginx.conf
    或 cd到你的 hello 使用 nginx -c conf/nginx.conf
  • 如果启动报错 resty.core 找不不到, 就把nginx安装目录中的lua,luaLib 两个⽂件夹复制到project ⾥面去 。

5.修改配置之后使⽤ ./nginx -s reload 重启。

  1. 停⽌./nginx -s stop

conterOS 安装 OpenResty

官⽅说明:OpenResty® 是一个基于 Nginx 与 Lua 的⾼性能 Web 平台,其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项。用于搭建超高并发、扩展性极高的动态 Web 应用、Web 服务和动态⽹关。
下载地址:
OpenResty官⽹: http://openresty.org/
OpenResty下载地址:http://openresty.org/cn/download.html

  1. 安装依赖库:
$ yum install -y pcre-devel openssl-devel gcc curl

2.下载OpenResty版本:

 $ wget https://openresty.org/download/openresty-1.15.8.1.tar.gz
wget https://openresty.org/download/openresty-1.21.4.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的软连接。
7.常用命令:

查看版本号:
$ /usr/local/openresty/bin/openresty -v
  nginx version: openresty/1.15.8.3
检验配置
/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

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

$ systemctl daemon-reload

10.使用systemctl管理openresty:

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

相关文章

  • openresty起步

    openresty 安装openresty 1、源码安装 安装前准备: 源码下载地址:openresty 解压、安...

  • 运维之OpenResty

    运维之OpenResty 目录 OpenResty简单介绍 在win上安装OpenResty 在linux上安装O...

  • Ansible Role WEB 之【openresty】

    Ansible Role: openresty 安装openresty 介绍 OpenResty® 是一个基于 N...

  • lapis 框架安装试用

    备注: 此次安装使用的是openresty 的openresty-1.11.2.1(openresty-1.11....

  • Openresty-1.11.2.2安装

    Openresty-1.11.2.2安装 OpenResty简介 ​ OpenResty 是一个基于 Ngin...

  • OpenResty 基于 lua-resty-cookie 实现

    openresty 安装 openresty lua-resty-cookie 实现灰度功能

  • 一、安装教程

    安装 添加官方软件包到yum中 安装OpenResty 安装OpenResty 的 CLI工具 检验image.p...

  • openresty

    1、openResty安装 centos 安装 2、openresty配置 nginx匹配规则 服务端获得客户端...

  • Ubuntu 源码安装Kong

    安装openresty 1.下载openssl-1.0.2h 2.下载openresty 官方安装指引:https...

  • nginx openresty

    openResty安装 centos 添加yum仓库,安装 openresty配置 服务端获得客户端的真实ip ...

网友评论

      本文标题:安装OpenResty

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