본문 바로가기

여행

nginx 빌드하여 설치하기

nginx 1.9.6 을 운용중이었지만, nginx 1.9.7 이 나와서 업데이트를 해보려고합니다.


벌써 3번째 업데이트 군요.


nginx 가 실행중이기 때문에 pkill nginx 로 먼저 죽입니다. make install 할때 죽이셔도 상관없습니다.


wget http://nginx.org/download/nginx-1.9.7.tar.gz

를 통해 nginx 를 받아옵니다.

tar zxvf nginx-1.9.7.tar.gz

를 통해 압축을 풉니다.



저는 gd 라이브러리, HTTPS 통신을 위해 OpenSSL, PCRE, Zlib 와 함께 컴파일을 진행할 것입니다.


소스패키지를 압축을 풀어놓고, 아니면 yum 이나 apt-get 을 이용해 devel, dev 패키지를 받아오셔도 됩니다.


./configure --prefix=/etc/nginx --sbin-path=/etc/nginx/nginx --conf-path=/etc/nginx/nginx.conf --with-http_ssl_module --with-pcre=pcre --with-zlib=zlib-1.2.8 --with-http_v2_module --with-openssl=openssl

--prefix = nginx 설치 위치
--sbin-path =  nginx 실행 파일 경로 (옵션)
--conf-path = nginx.conf 경로 ( 옵션)
--with-http_ssl_module = SSL 통신 모듈 활성화
--with-pcre=<path> = PCRE 소스 위치 (옵션, 이미 설치되어있으면 <path> 생략 가능)
--with-zlib=<path> = ZLIB 소스 위치 (옵션, 이미 설치되어있으면 <path> 생략 가능)
--with-http_v2_module = HTTP/2 모듈 활성화 (옵션, nginx 1.9.5 이상)
--with-openssl=<path> = OpenSSL 소스 위치 (옵션, http_ssl_module 활성화 시 필수, 이미 설치되어있으면 <path> 생략 가능)
 
http://nginx.org/en/docs/configure.html
에서도 다른 옵션이나 자세한 설명을 보실 수 있습니다.


설정이 완료되면 설정 상태가 나오는데, 필요에 따라 조절해주시면 됩니다.


make

를 입력하여 빌드를 시작합니다.


make install

빌드가 완료되면 설치를 시작합니다.

nginx 가 이미 켜져있므면 오류가 뜨게됩니다.



설치가 완료되었습니다.


ln /etc/nginx/sbin /usr/local/nginx

를 통해 nginx 명령어를 등록합니다.


nginx 1.9.7 이 작동하기 시작합니다.