티스토리 뷰

Docker

Docker : nginx 1.20.1 컴파일 설치

파란크리스마스 2025. 1. 12. 15:24
728x90

Ubuntu 도커 이미지 설치

D:\docker>docker run -it ^
--hostname 0.0.0.0 ^
--publish 1080:80 --publish 1443:443 --publish 1880:8080 ^
--name bxmas-ubuntu ^
--restart always ^
--volume //d/docker/bxmas/bxmas_home:/usr/local/bxmas_home ^
ubuntu:22.04 ^
/bin/bash
 
root@0:/#

OS 업데이트

root@0:/# apt update
root@0:/# apt upgrade

Linux 쉘 접속

D:\docker>docker ps
CONTAINER ID   IMAGE          COMMAND       CREATED       STATUS          PORTS                                                                 NAMES
7ce950bfb3c5   ubuntu:22.04   "/bin/bash"   4 hours ago   Up 18 minutes   0.0.0.0:1080->80/tcp, 0.0.0.0:1443->443/tcp, 0.0.0.0:1880->8080/tcp   cnssm-ubuntu
 
D:\docker>docker exec -it 7ce950bfb3c5 /bin/bash
root@0:/#

openjdk 17 설치

jdk 설치

root@0:/# apt install openjdk-17-jdk

JAVA_HOME 설정

root@0:/# echo "export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")" | tee /etc/profile.d/java_home.sh
root@0:/# source /etc/profile.d/java_home.sh

java 설치 확인

root@0:/# java --version
openjdk 17.0.13 2024-10-15
OpenJDK Runtime Environment (build 17.0.13+11-Ubuntu-2ubuntu122.04)
OpenJDK 64-Bit Server VM (build 17.0.13+11-Ubuntu-2ubuntu122.04, mixed mode, sharing)
root@0:/# javac --version
javac 17.0.13
root@0:/# echo $JAVA_HOME
/usr/lib/jvm/java-17-openjdk-amd64
root@0:/#

nginx 설치

nginx 계정 생성

root@0:~# useradd nginx -s /sbin/nologin

nginx 빌드 환경 설정

root@0:~# apt install gcc g++ make perl
root@0:~# mkdir nginx_source
root@0:~# cd nginx_source/
root@0:~/nginx_source# apt install wget
root@0:~/nginx_source# wget https://nginx.org/download/nginx-1.20.1.tar.gz
root@0:~/nginx_source# tar xvf nginx-1.20.1.tar.gz
root@0:~/nginx_source# wget  https://sourceforge.net/projects/pcre/files/pcre/8.45/pcre-8.45.tar.gz
root@0:~/nginx_source# tar xvf pcre-8.45.tar.gz
root@0:~/nginx_source# wget https://www.openssl.org/source/openssl-1.1.1l.tar.gz
root@0:~/nginx_source# tar -xzvf openssl-1.1.1l.tar.gz
root@0:~/nginx_source# wget https://www.zlib.net/fossils/zlib-1.2.11.tar.gz
root@0:~/nginx_source# tar xvf zlib-1.2.11.tar.gz
root@0:~/nginx_source# cd nginx-1.20.1/
root@0:~/nginx_source/nginx-1.20.1#

configure

root@0:~/nginx_source/nginx-1.20.1# ./configure \
--user=nginx \
--group=nginx \
--with-http_sub_module \
--with-zlib=../zlib-1.2.11 \
--with-pcre=../pcre-8.45 \
--with-openssl=../openssl-1.1.1l \
--with-http_ssl_module \
--prefix=/usr/local/nginx \
--conf-path=/usr/local/bxmas_home/nginx_conf/nginx.conf
 
Configuration summary
  + using PCRE library: ../pcre-8.45
  + using OpenSSL library: ../openssl-1.1.1l
  + using zlib library: ../zlib-1.2.11
 
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/bxmas_home/nginx_conf"
  nginx configuration file: "/usr/local/bxmas_home/nginx_conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

make

root@0:~/nginx_source/nginx-1.20.1# make
 
-lcrypt ../pcre-8.45/.libs/libpcre.a ../openssl-1.1.1l/.openssl/lib/libssl.a ../openssl-1.1.1l/.openssl/lib/libcrypto.a ../zlib-1.2.11/libz.a \
-Wl,-E
sed -e "s|%%PREFIX%%|/usr/local/nginx|" \
        -e "s|%%PID_PATH%%|/usr/local/nginx/logs/nginx.pid|" \
        -e "s|%%CONF_PATH%%|/usr/local/bxmas_home/nginx_conf/nginx.conf|" \
        -e "s|%%ERROR_LOG_PATH%%|/usr/local/nginx/logs/error.log|" \
        < man/nginx.8 > objs/nginx.8
make[1]: Leaving directory '/root/nginx_source/nginx-1.20.1'

make install

root@0:~/nginx_source/nginx-1.20.1# make install
make -f objs/Makefile install
make[1]: Entering directory '/root/nginx_source/nginx-1.20.1'
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin' \
        || mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' \
        || mv '/usr/local/nginx/sbin/nginx' \
                '/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/bxmas_home/nginx_conf' \
        || mkdir -p '/usr/local/bxmas_home/nginx_conf'
cp conf/koi-win '/usr/local/bxmas_home/nginx_conf'
cp conf/koi-utf '/usr/local/bxmas_home/nginx_conf'
cp conf/win-utf '/usr/local/bxmas_home/nginx_conf'
test -f '/usr/local/bxmas_home/nginx_conf/mime.types' \
        || cp conf/mime.types '/usr/local/bxmas_home/nginx_conf'
cp conf/mime.types '/usr/local/bxmas_home/nginx_conf/mime.types.default'
test -f '/usr/local/bxmas_home/nginx_conf/fastcgi_params' \
        || cp conf/fastcgi_params '/usr/local/bxmas_home/nginx_conf'
cp conf/fastcgi_params \
        '/usr/local/bxmas_home/nginx_conf/fastcgi_params.default'
test -f '/usr/local/bxmas_home/nginx_conf/fastcgi.conf' \
        || cp conf/fastcgi.conf '/usr/local/bxmas_home/nginx_conf'
cp conf/fastcgi.conf '/usr/local/bxmas_home/nginx_conf/fastcgi.conf.default'
test -f '/usr/local/bxmas_home/nginx_conf/uwsgi_params' \
        || cp conf/uwsgi_params '/usr/local/bxmas_home/nginx_conf'
cp conf/uwsgi_params \
        '/usr/local/bxmas_home/nginx_conf/uwsgi_params.default'
test -f '/usr/local/bxmas_home/nginx_conf/scgi_params' \
        || cp conf/scgi_params '/usr/local/bxmas_home/nginx_conf'
cp conf/scgi_params \
        '/usr/local/bxmas_home/nginx_conf/scgi_params.default'
test -f '/usr/local/bxmas_home/nginx_conf/nginx.conf' \
        || cp conf/nginx.conf '/usr/local/bxmas_home/nginx_conf/nginx.conf'
cp conf/nginx.conf '/usr/local/bxmas_home/nginx_conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' \
        || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' \
        || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' \
        || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' \
        || mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory '/root/nginx_source/nginx-1.20.1'

서비스 등록

/etc/init.d/nginx에서 환경파일(nginx.conf) 경로 수정 필요

root@0:~# wget --no-check-certificate https://raw.github.com/JasonGiedymin/nginx-init-ubuntu/master/nginx -O /etc/init.d/nginx
root@0:~# chmod +x /etc/init.d/nginx
root@0:~# update-rc.d -f nginx defaults
댓글
300x250
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함