CentOS7 安装 OpenResty
2019/1/25...大约 2 分钟
CentOS7 安装 OpenResty
OpenResty 基于 Nginx,每个 worker 使用一个 LuaVM,请求到来时在 LuaVM 内创建协程处理。协程之间数据隔离,各自拥有独立的全局变量
_G。OpenResty 致力于将服务器应用完全运行于 Nginx 中,充分利用 Nginx 事件模型进行非阻塞 I/O,对 MySQL、Redis、Memcached 的 I/O 操作同样非阻塞,可轻松应对 ==10K+== 并发连接。
安装
1. 添加 OpenResty 官方 yum 仓库
sudo yum install yum-utils
sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo2. 安装 OpenResty
sudo yum install openresty3. 安装命令行工具 resty
sudo yum install openresty-resty其他工具包
openresty-opm— 包管理工具 opmopenresty-doc— 文档工具 restydoc
4. 查看仓库中可用的软件包
sudo yum --disablerepo="*" --enablerepo="openresty" list available点击展开输出示例
Available Packages
openresty.x86_64 1.13.6.2-1.el7.centos openresty
openresty-resty.noarch 1.13.6.2-1.el7.centos openresty
openresty-opm.noarch 1.13.6.2-1.el7.centos openresty
openresty-doc.noarch 1.13.6.2-1.el7.centos openresty
openresty-debug.x86_64 1.13.6.2-1.el7.centos openresty
openresty-openssl.x86_64 1.1.0h-3.el7.centos openresty
openresty-pcre.x86_64 8.42-1.el7.centos openresty
openresty-zlib.x86_64 1.2.11-3.el7.centos openresty
...默认安装路径
安装完成后,OpenResty 默认位于 /usr/local/openresty:
cd /usr/local/openresty && ll目录结构
total 24
drwxr-xr-x. 2 root root 36 Jan 25 21:41 bin
-rw-r--r--. 1 root root 22924 May 15 2018 COPYRIGHT
drwxr-xr-x. 6 root root 56 Jan 25 21:40 luajit
drwxr-xr-x. 5 root root 59 Jan 25 21:40 lualib
drwxr-xr-x. 7 root root 68 Jan 25 21:40 nginx
drwxr-xr-x. 4 root root 28 Jan 25 21:40 openssl
drwxr-xr-x. 3 root root 17 Jan 25 21:40 pcre
drwxr-xr-x. 3 root root 20 Jan 25 21:40 zlib服务管理
sudo systemctl start openresty # 启动
sudo systemctl stop openresty # 停止
sudo systemctl restart openresty # 重启
sudo systemctl enable openresty # 开机自启
sudo systemctl status openresty # 查看状态提示
建议同时执行 enable,确保服务器重启后 OpenResty 自动拉起。
验证安装
启动后访问 http://localhost,看到 OpenResty 欢迎页即表示安装成功。
注意
CentOS7 防火墙默认拦截 80 端口,若无法访问请先放行:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload更新日志
2026/3/16 03:40
查看所有更新日志
68af6-于