리눅스 Openresty nginx 빌드 설치 with brotil
(데비안 10기준)에서 openresty 빌드설치하기…
openresty는 nginx에 이것저것 묶은 버전입니다.. 특히 LuaJIT이 달려있어 WAS를 스크립트로 더 자유자재로 다루고 싶을 때 사용합니다. 카카오 회사도 openresty를 사용한 것 같기도.
Openresty 소스 다운로드
https://openresty.org/en/download.html 이곳에서 다운로드 할 수 있다.
(현재기준) 최신버전은 openresty-1.19.3.1.tar.gz
mkdir -p /opt/openresty
wget -qO- https://openresty.org/download/openresty-1.19.3.1.tar.gz | tar xvz --strip 1 -C /opt/openresty
cd /opt/openresty
Google Brotil 모듈다운로드
brotil 모듈을 wordpress total cache에서 사용하는 탓에 나도 한번..
/opt/openresty# git clone --recursive https://github.com/google/ngx_brotli
brotil 모듈도 받아야 하기 때문에 recursive 옵션을 넣어준다
GeoIP 라이브러리 다운로드
여러모로 쓰일 것 같아서 GeoIP 모듈을 활성화 하는데 GeoIP 라이브러리가 필요하다
CentOS 8, 7
yum install GeoIP-devel
Debian 10, 9
apt install libgeoip-dev
Build
OpenSSL 소스와 함께 빌드 (느리다!!)
./configure --prefix=/usr/local/openresty \
--with-openssl=/opt/openssl-1.1.1h \
--with-compat \
--add-module=./ngx_brotli \
--with-pcre-jit \
--with-http_realip_module \
--with-http_geoip_module=dynamic \
--with-http_v2_module \
--with-http_gzip_static_module \
--with-http_slice_module \
--with-stream \
--with-stream_ssl_module
OpenSSL Shared로 빌드
./configure --prefix=/usr/local/openresty \
--with-cc-opt="-I /usr/local/ssl/include" \
--with-ld-opt="-L /usr/local/ssl/lib" \
--with-compat \
--add-module=./ngx_brotli \
--with-pcre-jit \
--with-http_realip_module \
--with-http_geoip_module=dynamic \
--with-http_v2_module \
--with-http_gzip_static_module \
--with-http_slice_module \
--with-stream \
--with-stream_ssl_module
make -j$(nproc) && make install
서비스 등록
cat > /lib/systemd/system/openresty.service << ___S___
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/usr/local/openresty/nginx/logs/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
___S___
chmod 755 /lib/systemd/system/openresty.service
systemctl daemon-reload
편의를 위해
ln -s /usr/local/openresty/bin/openresty /usr/sbin/nginx
ln -s /lib/systemd/system/openresty.service /lib/systemd/system/nginx.service
Nginx Configuration
생략..