Contents

[NGINX] CentOS 7에서 nginx 컴파일 설치하기

nginx 컴파일 설치하기

  • CentOS 7에서 NGINX를 컴파일 버전으로 설치한다.
  • 컴파일 설치를 하기 위해서는 몇 가지 라이브러리가 필요하다.
  • 필요 의존 라이브러리는 openssl, pcre, zlib 등이 필요하므로 먼저 설치한다.

컴파일을 위한 라이브러리 설치

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# pcre 라이브러리 설치
yum install pcre*

# gzip 압축을 사용하기 위해서 설치
yum install zlib zlib-devel

# open ssl 설치
yum install openssl openssl-devel

# gcc 설치
yum install gcc

nginx 소스 파일을 다운로드

1
2
3
4
5
6
7
cd /usr/local/src

# 원하는 버전 다운로드
wget http://nginx.org/download/nginx-1.14.0.tar.gz

# 압축해제
tar xzf nginx-1.14.0.tar.gz

컴파일

1
2
3
4
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --with-http_realip_module --with-http_v2_module --user=riley --group=riley

# 컴파일 후 인스톨
make && make install

실행 스크립트 생성

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# nginx-start.sh
#!/bin/sh
/usr/local/nginx/sbin/nginx

# nginx-stop.sh
#!/bin/sh
/usr/local/nginx/sbin/nginx -s stop

# nginx-reload.sh
#!/bin/sh
/usr/local/nginx/sbin/nginx -s reload

chmod +x nginx-*.sh