Souce Install Nginx with OpenSSL 1.1.1 on CentOS 7

CentOS 7 에서 OpenSSL 1.1.1 버전과 함께 Nginx 컴파일 설치하는 방법에 대한 예제

 

OpenSSL 보안 이슈 및 오래된 버전의 EOL 문제로 인해 최신버전을 권장 합니다.

https://umount.net/openssl-심각한-보안-취약점-발견-cve-2020-1967/

Nginx 설치시 configure 의 --with-openssl 옵션에 반드시 OpenSSL 설치 경로가 아닌 OpenSSL 원본소스 경로를 설정해 주어야 합니다.

 

의존성 패키지 설치

[root@172-16-11-99 /]# yum -y install gcc gcc-c++ autoconf make zlib-devel sqlite-devel

 

OpenSSL 다운로드 및 설치

[root@172-16-11-99 /]# cd /usr/local/src/
[root@172-16-11-99 src]# wget https://www.openssl.org/source/openssl-1.1.1g.tar.gz
[root@172-16-11-99 src]# tar xvzf openssl-1.1.1g.tar.gz
[root@172-16-11-99 src]# cd openssl-1.1.1g
[root@172-16-11-99 openssl-1.1.1g]# ./config --prefix=/usr/local/openssl-1.1.1g shared
[root@172-16-11-99 openssl-1.1.1g]# make -j$(nproc)
[root@172-16-11-99 openssl-1.1.1g]# make install

 

유저 생성

[root@172-16-11-99 openssl-1.1.1g]# useradd -M -r -s /sbin/nologin webuser

 

의존성 패키지 설치

[root@172-16-11-99 openssl-1.1.1g]# yum install gcc gcc-c++ pcre-devel zlib-devel

 

Nginx 1.18.0 다운로드 및 설치

[root@172-16-11-99 openssl-1.1.1g]# cd /usr/local/src/
[root@172-16-11-99 src]# wget http://nginx.org/download/nginx-1.18.0.tar.gz
[root@172-16-11-99 src]# tar xvzf nginx-1.18.0.tar.gz
[root@172-16-11-99 src]# cd nginx-1.18.0
[root@172-16-11-99 nginx-1.18.0]# ./configure \
--prefix=/data/apps/src/nginx-1.18.0 \
--sbin-path=/data/apps/src/nginx-1.18.0/sbin/nginx \
--pid-path=/data/apps/src/nginx-1.18.0 \
--conf-path=/data/apps/src/nginx-1.18.0/conf/nginx.conf \
--user=webuser \
--group=webuser \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-openssl=/usr/local/src/openssl-1.1.1g \
--http-client-body-temp-path=/data/apps/src/nginx-1.18.0/tmp/_client_body \
--http-proxy-temp-path=/data/apps/src/nginx-1.18.0/tmp/_proxy \
--http-fastcgi-temp-path=/data/apps/src/nginx-1.18.0/tmp/_fastcgi \
--http-uwsgi-temp-path=/data/apps/src/nginx-1.18.0/tmp/_uwsgi \
--http-scgi-temp-path=/data/apps/src/nginx-1.18.0/tmp/_scgi
[root@172-16-11-99 nginx-1.18.0]# make -j$(nproc)
[root@172-16-11-99 nginx-1.18.0]# make install

 

tmp 디렉토리 생성 및 불필요한 파일 제거

[root@172-16-11-99 nginx-1.18.0]# mkdir -p /data/apps/src/nginx-1.18.0/tmp
[root@172-16-11-99 nginx-1.18.0]# rm -Rf /data/apps/src/nginx-1.18.0/conf/*.default

 

nginx.conf 수정
: vi /data/apps/src/nginx-1.18.0/conf/nginx.conf
자신의 사이트 환경에 맞게 필요한 부분을 수정합니다.

 

systemd 파일 생성
: vi /etc/systemd/system/nginx.service

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/data/apps/src/nginx-1.18.0/nginx.pid
ExecStartPre=/data/apps/src/nginx-1.18.0/sbin/nginx -t
ExecStart=/data/apps/src/nginx-1.18.0/sbin/nginx
ExecReload=/data/apps/src/nginx-1.18.0/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
ExecStopPost=/bin/rm -f /run/nginx.pid
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

systemd 등록 및 실행

[root@172-16-11-99 nginx-1.18.0]# systemctl enable nginx
[root@172-16-11-99 nginx-1.18.0]# systemctl start nginx

 

Nginx 정보 확인 (OpenSSL 1.1.1 확인)

[root@172-16-11-99 nginx-1.18.0]# /data/apps/src/nginx-1.18.0/sbin/nginx -V
nginx version: nginx/1.18.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.1.1g 21 Apr 2020
TLS SNI support enabled
configure arguments: --prefix=/data/apps/src/nginx-1.18.0 --sbin-path=/data/apps/src/nginx-1.18.0/sbin/nginx --pid-path=/data/apps/src/nginx-1.18.0 --conf-path=/data/apps/src/nginx-1.18.0/conf/nginx.conf --user=webuser --group=webuser --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-openssl=/usr/local/src/openssl-1.1.1g --http-client-body-temp-path=/data/apps/src/nginx-1.18.0/tmp/_client_body --http-proxy-temp-path=/data/apps/src/nginx-1.18.0/tmp/_proxy --http-fastcgi-temp-path=/data/apps/src/nginx-1.18.0/tmp/_fastcgi --http-uwsgi-temp-path=/data/apps/src/nginx-1.18.0/tmp/_uwsgi --http-scgi-temp-path=/data/apps/src/nginx-1.18.0/tmp/_scgi

You may also like...

Subscribe
Notify of
guest

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x