Nginx

Nginx - 컴파일해서 사용하자

빠빠담 2020. 9. 19. 20:06
반응형

 

그동안 패키지로 간단하게 사용하였다

추가적인 모듈이 필요 없었다.

 

하지만 대용량 파일 업로드를 구현하기 위해

nginx-upload-module

을 추가적으로 설치해야했다.

 

컴파일을 시작해보자 


우선 컴파일에 필요한 라이프러리와 패키지를 설치하자

$ sudo apt-get install \
make libperl-dev libpcre3 libpcre3-dev zlib1g \
zlib1g-dev openssl libssl-dev libxml2-dev libxslt1-dev \
libgd-dev libgeoip-dev google-perftools libgoogle-perftools-dev gcc g++

 

Nginx를 다운 받는다 글작성 현재 Stable version 1.18.0이다

# Nginx 공식 홈페이지를 참고하자
# https://nginx.org/en/download.html

$ wget https://nginx.org/download/nginx-1.18.0.tar.gz
$ tar -xvzf nginx-1.18.0.tar.gz

 

내가 사용할 추가 모듈은 nginx-upload-module 이다

# https://www.nginx.com/resources/wiki/modules/upload/

$ wget -P /tmp https://github.com/vkholodkov/nginx-upload-module/archive/2.3.0.tar.gz
$ tar -zxvf /tmp/2.3.0.tar.gz -C /tmp

 

컴파일 환경설정

./configure \
--sbin-path=/usr/local/sbin/nginx \
--conf-path=/usr/local/nginx/nginx.conf \
--pid-path=/var/run/nginx.pid \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module \
--with-http_image_filter_module \
--with-http_geoip_module \
--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_slice_module \
--with-http_degradation_module \
--with-http_stub_status_module \
--with-http_perl_module \
--with-mail \
--with-mail_ssl_module \
--with-stream \
--with-stream_ssl_module \
--with-google_perftools_module \
--with-cpp_test_module \
--with-debug \

# 추가된 모듈
--add-module=/tmp/nginx-upload-module-2.3.0

 

만약 패키지설치와 같은 환경설정 폴더를 사용하고 싶다면

아래와 같이 설정하자 (위 설정에서 3번째 줄을 지우고 아래의 설정을 입력한다)

--prefix=/usr/share/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/error.log \
--http-log-path=/var/log/access.log \

설정 완료

 

컴파일 및 설치

$ make
$ sudo make install

에러 없이 디렉토리에서 나갔다라고 뜨면 완료

 

패키지와 달리($ sudo service nginx status)

서비스는 /usr/local/sbin/nginx binary 파일을 사용한다.

(위의 컴파일전 환경설정에서 binary 파일의 경로를 설정할 수 있다

아래는 기본 설정의 경로이다.)

/usr/local/sbin/nginx // 서비스 시작
/usr/local/sbin/nginx -s stop // 서비스 정지
/usr/local/sbin/nginx -s reload // 서비스 재시작
/usr/local/sbin/nginx -t // 설정 파일 syntax 테스트

 

 

 


 

참고 사이트

https://serverfault.com/questions/682113/how-to-install-nginx-upload-module-on-production-server

 

How to install nginx-upload-module on production server?

My nginx server was installed by the following approach: sudo add-apt-repository ppa:nginx/stable sudo apt-get update && sudo apt-get install nginx Now I need to https://github.com/vkholo...

serverfault.com

https://extrememanual.net/9910

 

우분투 NGINX 컴파일 설치 방법 - 익스트림 매뉴얼

이전 포스트에서 우분투에 NGINX를 패키지로 설치하는 방법에 대해 알아봤는데요. 서비스 명령어나 방화벽, 로그 로테이트 설정 같은 부가적인 기능을 별도로 설정할 필요가 없기 때문에 패키지�

extrememanual.net

 

반응형