OpenResty 란

OpenResty 는 nginx core 기반의 web platform 제품으로 향상된 LuaJIT 을 내장하고 신중하게 작성된 Lua 라이브러리와 고품질의 3 rd party nginx module 을 탑재한 제품입니다.

개발자들이 쉽고 빠르게 확장 가능한 웹 애플리케이션과 웹 서비스를 구성할 수 있도록 설계되었으며 최적의 성능을 끌어내도록 효과적으로 구성하면 단일 장비에서 10 K ~ 1,000K 까지의 커넥션을 처리할 수 있습니다.


OpenResty 는 nginx 의 비동기 event model 을 사용해서 HTTP Client 를 처리할 수 있지만 MySQL 이나 PostgreSQL, Redis 의 remote backend 로 동작할 수 있습니다.


이제 OpenResty 는 nginx 의 fork 가 아니라 Nginx 를 하나의 component 로 사용하는 고성능 application & gateway platform 입니다.

OpenResty 는 세계에서 4번째로 많이 사용되는 Web Server 입니다.


설치

OSX

brew tap openresty/brew
brew install openresty
BASH


Ubuntu

먼저 nginx 를 사용중이면 중지합니다.

sudo systemctl disable nginx
sudo systemctl stop nginx
BASH


의존성있는 app 을 설치합니다.

sudo apt-get -y install --no-install-recommends wget gnupg ca-certificates
BASH


GPG 키를 import 합니다.

wget -O - https://openresty.org/package/pubkey.gpg | sudo apt-key add -
BASH


APT repository 를 등록합니다.

echo "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main" \
    | sudo tee /etc/apt/sources.list.d/openresty.list
BASH


APT index 를 갱신하고 설치합니다.

sudo apt update
sudo apt install -y openresty
BASH


CentOS/Rocky Linux


yum repository 를 추가합니다.

wget https://openresty.org/package/centos/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/
BASH


저장소에서 openresty 를 설치합니다.

sudo yum install openresty openresty-resty
BASH


Amazon Linux

repository 를 추가합니다.

wget https://openresty.org/package/amazon/openresty.repo
sudo mv openresty.repo /etc/yum.repos.d/
BASH


패키지를 설치합니다.

sudo yum install -y openresty openresty-resty
BASH


서비스 설정

설치가 끝났으면 PATH 가 잘 설정됐는지 확인하기 위해 openresty 명령을 실행해 봅니다.

$ openresty -V

nginx version: openresty/1.19.9.1
built by gcc 8.4.1 20200928 (Red Hat 8.4.1-1) (GCC) 
built with OpenSSL 1.1.1k  25 Mar 2021
TLS SNI support enabled
configure arguments: --prefix=/usr/local/openresty/nginx --with-cc-opt='-O2 -DNGX_LUA_ABORT_AT_PANIC
BASH


설정 파일의 이상 유무는 nginx 와 마찬가지로 -t 옵션으로 확인하면 됩니다.

$ openresty -t

nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successful
BASH

이미 nginx 가 설치되어 있을 경우 nginx 명령을 사용하면 예전 nginx 가 구동될수 있으므로 대신 openresty 명령을 사용하는 걸 권장합니다.



이제 systemctl 로 openresty 서비스를 활성화해 줍니다.

sudo systemctl enable openresty
sudo systemctl start openresty
CODE


웹 브라우저로 연결해서 OpenResty 가 정상 동작하는지 확인하면 됩니다.


⏭️ OpenResty 설정하기

같이 보기

Ref