centos7编译安装openresty+lua-resty-http+lua-resty-openssl-master

OpenResty 是一个基于 Nginx 的高性能 Web 平台,它将 Nginx 服务器与 Lua 脚本语言紧密集成在一起,从而使得用户可以使用 Lua 编写各种 Web 应用和服务。OpenResty 提供了一系列的模块和工具,使得开发人员可以轻松地构建动态 Web 应用程序、RESTful API、微服务等。

主要特点

  1. 高性能:OpenResty 基于 Nginx,这使得它可以处理大量并发连接和请求,表现出色。

  2. Lua 脚本支持:通过将 Lua 脚本语言嵌入 Nginx,开发人员可以用 Lua 编写复杂的业务逻辑,包括处理 HTTP 请求、操作数据库等。

  3. 丰富的模块 :OpenResty 附带了许多实用的模块(如 lua-resty-httplua-resty-sessionlua-resty-redis 等),这些模块可以帮助开发人员实现各种功能,如 API 调用、会话管理、缓存等。

  4. 良好的扩展性:开发人员可以方便地编写自定义的 Lua 模块,扩展 OpenResty 的功能。

  5. 友好的开发体验:OpenResty 提供了良好的开发工具和文档支持,使得开发人员能够快速上手。

  6. 广泛应用:由于其高性能和灵活性,OpenResty 已被许多大型网站和应用广泛采用,如 GitHub、Taobao、知乎等。

在 CentOS 7 上编译安装 OpenResty 1.25.3.1:

1. 环境准备

确保系统是最新的,并安装必要的依赖包:

复制代码
sudo yum update
sudo yum install -y gcc gcc-c++ make curl unzip zlib-devel pcre-devel openssl-devel git

2. 下载并安装 OpenResty 1.25.3.1

2.1 下载 OpenResty

访问 OpenResty 下载页面 或直接使用 wget 下载指定版本:

复制代码
wget https://openresty.org/download/openresty-1.25.3.1.tar.gz
tar -zxvf openresty-1.25.3.1.tar.gz
cd openresty-1.25.3.1/
2.2 编译和安装 OpenResty
复制代码
./configure --prefix=/usr/local/openresty
make
sudo make install
2.3 设置环境变量

将 OpenResty 的二进制文件路径添加到路径中:

复制代码
echo 'export PATH=$PATH:/usr/local/openresty/bin' >> ~/.bashrc
source ~/.bashrc

在OpenResty中安装插件lua-resty-http

1. 下载 lua-resty-http

首先,使用 curlwget 下载指定版本的 tar.gz 压缩包:

复制代码
# 使用 curl 下载
curl -LO https://github.com/ledgetech/lua-resty-http/archive/refs/tags/v0.17.2.tar.gz

# 或使用 wget 下载
wget https://github.com/ledgetech/lua-resty-http/archive/refs/tags/v0.17.2.tar.gz

2. 解压缩文件

解压缩下载的文件:

复制代码
tar -xzvf v0.17.2.tar.gz

这将创建一个名为 lua-resty-http-0.17.2 的文件夹。

3. 移动模块到 OpenResty 的合适目录

将解压后的 lua-resty-http 模块移动到 OpenResty 的 lualib/resty/ 目录下。例如,如果 OpenResty 安装在 /usr/local/openresty 目录下,执行以下命令:

复制代码
sudo mkdir -p /usr/local/openresty/lualib/resty/  # 创建目标目录(如果不存在)
sudo mv lua-resty-http-0.17.2/lib/resty/http.lua /usr/local/openresty/lualib/resty/
sudo mv lua-resty-http-0.17.2/lib/resty/http_header.lua /usr/local/openresty/lualib/resty/
sudo mv lua-resty-http-0.17.2/lib/resty/http_connect.lua /usr/local/openresty/lualib/resty/

在OpenResty中安装插件lua-resty-openssl

1. 下载 lua-resty-openssl

使用 git 克隆源代码库:

复制代码
git clone https://github.com/fffonion/lua-resty-openssl.git

如果没有安装 git,你也可以直接访问 该链接 并下载 ZIP 文件,然后解压。

2. 移动模块到 OpenResty 的合适目录

假设你在 /usr/local/openresty 目录中安装了 OpenResty,使用以下命令将模块移动到 OpenResty 的 lualib 目录:

复制代码
# 创建目标目录(如果不存在)
sudo mkdir -p /usr/local/openresty/lualib/resty/

# 移动 lua-resty-openssl 的目录到目标位置
sudo mv lua-resty-openssl/lib/resty/openssl.lua /usr/local/openresty/lualib/resty/
sudo mv lua-resty-openssl/lib/resty/openssl/* /usr/local/openresty/lualib/resty/openssl/
相关推荐
LiuYaoheng28 分钟前
【Android】View 的基础知识
android·java·笔记·学习
星梦清河36 分钟前
宋红康 JVM 笔记 Day14|垃圾回收概述
jvm·笔记
小鸡脚来咯39 分钟前
一个Java的main方法在JVM中的执行流程
java·开发语言·jvm
江团1io040 分钟前
深入解析三色标记算法
java·开发语言·jvm
Suckerbin1 小时前
Basic Pentesting: 1靶场渗透
笔记·安全·web安全·网络安全
一枝花算不算浪漫1 小时前
线上频繁FullGC?慌得一比!竟是Log4j2的这个“特性”坑了我
jvm·后端
草莓熊Lotso1 小时前
PyCharm 从入门到高效:安装教程 + 快捷键速查表
开发语言·ide·经验分享·笔记·其他
一位搞嵌入式的 genius1 小时前
ES6 核心特性详解:从变量声明到函数参数优化
前端·笔记·学习
序属秋秋秋2 小时前
《C++进阶之STL》【set/map 使用介绍】
开发语言·c++·笔记·leetcode·stl·set·map
王伯安呢3 小时前
Java开发环境配置入门指南
java·开发语言·jvm·eclipse·环境搭建·新手