nginx 1.25.x 컴파일 방법 - ubuntu

최근 nginx의 컴파일 방식이 변경되어 변경된 방식에 대한 컴파일 방법을 정리
nginx 1.25.2 소스 버전을 대상으로 정리

1. nginx 소스 다운로드

# cd /root
# wget https://github.com/nginx/nginx/archive/refs/tags/release-1.25.2.tar.gz
# tar xvzf release-1.25.2.tar.gz

 

2. header more module 추가를 위한 다운로드

# cd /root
# git clone https://github.com/openresty/headers-more-nginx-module.git

 

3. 컴파일 시, 필요한 개발 라이브러리 패키지 설치

# apt install -y build-essential
# apt install -y libpcre3-dev
# apt install -y libssl-dev
# apt install -y zlib1g-dev
# apt install -y libxml2-dev
# apt install -y libxslt1-dev
# apt install -y libgd-dev
# apt install -y libgeoip-dev

 

4. nignx 컴파일

# cd /root
# cd nginx-release-1.25.2

# ./auto/configure  --prefix=/usr/local/nginx \
  --conf-path=/usr/local/nginx/etc/nginx.conf \
  --http-log-path=/usr/local/nginx/log/access.log \
  --error-log-path=/usr/local/nginx/log/error.log \
  --lock-path=/var/lock/nginx.lock \
  --pid-path=/run/nginx.pid \
  --modules-path=/usr/local/nginx/modules \
  --http-client-body-temp-path=/usr/local/nginx/temp/body \
  --http-fastcgi-temp-path=/usr/local/nginx/temp/fastcgi \
  --http-proxy-temp-path=/usr/local/nginx/temp/proxy \
  --http-scgi-temp-path=/usr/local/nginx/temp/scgi \
  --http-uwsgi-temp-path=/usr/local/nginx/temp/uwsgi \
  --with-http_ssl_module \
  --with-http_v2_module \
  --with-http_v3_module \
  --with-http_realip_module \
  --with-http_addition_module \
  --with-http_xslt_module=dynamic \
  --with-http_image_filter_module=dynamic \
  --with-http_geoip_module=dynamic \
  --with-http_sub_module \
  --with-http_dav_module \
  --with-http_flv_module \
  --with-http_mp4_module \
  --with-http_gunzip_module \
  --with-http_gzip_static_module \
  --with-http_auth_request_module \
  --with-http_random_index_module \
  --with-http_secure_link_module \
  --with-http_degradation_module \
  --with-http_slice_module \
  --with-http_stub_status_module \
  --with-mail=dynamic \
  --with-mail_ssl_module \
  --with-stream=dynamic \
  --with-stream_ssl_module \
  --with-stream_realip_module \
  --with-stream_geoip_module \
  --with-stream_ssl_preread_module \
  --with-debug \
  --add-module=/root/headers-more-nginx-module
  
  # make
  # make install
  
  위 컴파일 시, 적용된 /usr/local/nginx/temp 디렉토리는 install 시 생성되지 않아 install 후, 생성
  # mkdir -p /usr/local/nginx/temp

 

위와 같이 진행한다.