OpenResty® 是一个基于 Nginx 与 Lua 的高性能 Web 平台,其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项。用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关。
OpenResty® 通过汇聚各种设计精良的 Nginx 模块(主要由 OpenResty 团队自主开发),从而将 Nginx 有效地变成一个强大的通用 Web 应用平台。这样,Web 开发人员和系统工程师可以使用 Lua 脚本语言调动 Nginx 支持的各种 C 以及 Lua 模块,快速构造出足以胜任 10K 乃至 1000K 以上单机并发连接的高性能 Web 应用系统。
OpenResty® 的目标是让你的Web服务直接跑在 Nginx 服务内部,充分利用 Nginx 的非阻塞 I/O 模型,不仅仅对 HTTP 客户端请求,甚至于对远程后端诸如 MySQL、PostgreSQL、Memcached 以及 Redis 等都进行一致的高性能响应。
参考 组件 可以知道 OpenResty® 中包含了多少软件。
参考 上路 学习如何从最简单的 hello world 开始使用 OpenResty® 开发 HTTP 业务,或前往 下载 直接获取 OpenResty® 的源代码包开始体验。
yum源安装
# add the yum repo:wget https://openresty.org/package/centos/openresty.reposudo mv openresty.repo /etc/yum.repos.d/# update the yum index:sudo yum check-update#然后就可以像下面这样安装软件包,比如 openresty:sudo yum install -y openresty#如果你想安装命令行工具 resty,那么可以像下面这样安装 openresty-resty 包:sudo yum install -y openresty-resty#命令行工具 opm 在 openresty-opm 包里,而 restydoc 工具在 openresty-doc 包里头。#列出所有 openresty 仓库里头的软件包:sudo yum --disablerepo="*" --enablerepo="openresty" list available#参考 OpenResty RPM 包页面#http://openresty.org/cn/rpm-packages.html#获取这些包更多的细节。#对于 CentOS 8 及更新版本,我们只需要将上面的 yum 命令都替换成 dnf 即可。
Centos源码编译安装
各个系统OpenResty® Linux 包 http://openresty.org/cn/linux-packages.html
下载最新源码
当前最新版本为2020年11月6日更新
wget https://openresty.org/download/openresty-1.19.3.1.tar.gztar -xvf openresty-1.19.3.1.tar.gz# 安装相关依赖yum -y install gcc automake autoconf libtool make openssl openssl-develyum -y install gcc gcc-c++# 这明明是官方提供的命令行,但是它本身又不提供 postgresql-devel 只能自己手动安装yum install -y postgresql-develyum install -y pcre-devel openssl-devel gcc postgresql-devel# 自定义目录安装# 默认路径为--prefix=/usr/local/openresty./configure --prefix=/data/openresty --user=root --group=root \--with-luajit \--without-http_redis2_module \--with-http_iconv_module \--with-http_postgres_module \--with-threads \--with-http_realip_module \--with-http_ssl_module \--with-stream \--with-stream_ssl_module \--with-http_stub_status_module \--with-http_gzip_static_module \--with-http_slice_module# 编译安装fmake -j `nproc ` && make install
