Linux服务器使用Docker安装OpenResty
2025年11月21日
170字

前言

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

这篇文章的主要目的就是使用docker安装OpenResty

安装

前期准备

安装docker

My terminal window
curl -sSL https://get.docker.com| sudo bash

安装OpenResty

新建一个目录,用于存放OpenResty的docker-compose.yml文件

将以下内容写入docker-compose.yml文件,可以对文件进行适当调整

services:
openresty:
image: openresty/openresty:latest-alpine # alpine镜像体积小巧
network_mode: "host" # 使用host网络,方便反向代理
environment:
- TZ=Asia/Shanghai # 设置时区
restart: always # 重启策略
volumes:
- /etc/nginx/conf.d:/etc/nginx/conf.d
- /etc/nginx/logs:/usr/local/openresty/nginx/logs
- /etc/nginx/html:/etc/nginx/html
- /home/ubuntu/.acme.sh:/etc/nginx/ssl # 映射ssl证书目录

在当前目录下运行以下命令

My terminal window
sudo docker compose up -d

至此已经使用docker成功安装了OpenResty

——END——
# Linux
# Ubuntu
# 运维
作者信息:Gaze.
发表于:2025年11月21日