본문 바로가기

Tools/WordPress

WordPress | Ubuntu 22.04 + NGNIX 1.27

 

Ubuntu 저장소에서 NGINX를 설치하면 1.8.0 버전이 설치되는데, 1.2x 부터 성능 최적화 (CPU, 메모리 사용량 감소) 및 HTTP/2 지원 등 최신 기술이 반영되어 있다.

 

NGINX 홈페이지에 나와있는 취약점 정보를 참고해서 본인 환경에 적절한 버전을 찾아 설치하면 된다.

https://nginx.org/en/security_advisories.html

 

nginx security advisories

nginx security advisories All nginx security issues should be reported to security-alert@nginx.org. Patches are signed using one of the PGP public keys. Buffer overread in the ngx_http_mp4_moduleSeverity: lowAdvisoryCVE-2024-7347Not vulnerable: 1.27.1+, 1.

nginx.org

 

현재 설치된 버전 확인 (대문자 V 사용)

razor1911@ubuntu:/var/www/html$ nginx -V
nginx version: nginx/1.18.0 (Ubuntu)
built with OpenSSL 3.0.2 15 Mar 2022
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -ffile-prefix-map=/build/nginx-zctdR4/nginx-1.18.0=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-compat --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --add-dynamic-module=/build/nginx-zctdR4/nginx-1.18.0/debian/modules/http-geoip2 --with-http_addition_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_sub_module
razor1911@ubuntu:/var/www/html$

 

현재 설정 백업

sudo cp -r /etc/nginx /etc/nginx-backup

 

 

키 다운로드

razor1911@ubuntu:~$ wget http://nginx.org/keys/nginx_signing.key
razor1911@ubuntu:~$ sudo apt-key add nginx_signing.key

 

소스 추가

echo "deb http://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" | sudo tee /etc/apt/sources.list.d/nginx.list

 

설치 가능 버전 확인

sudo apt-get update
sudo apt-cache showpkg nginx

 

최신 버전으로 설치 진행

sudo apt-get install nginx

 

설정 파일 그대로 보존

Configuration file '/etc/nginx/nginx.conf'
 ==> Modified (by you or by a script) since installation.
 ==> Package distributor has shipped an updated version.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** nginx.conf (Y/I/N/O/D/Z) [default=N] ? N

 

업데이트 후 버전 확인

razor1911@ubuntu:~$ nginx -V
nginx version: nginx/1.27.1
built by gcc 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)
built with OpenSSL 3.0.2 15 Mar 2022

 

만약 서버에서 80 포트를 이미 다른 웹 서비스에서 사용 중이라면

1.18 에서 1.27로 업데이트 후, 서비스가 실행되지 않을 수 있다.

 

아래 명령으로 사용 중인 프로세스를 확인할 수 있다.

sudo lsof -i :80

 

프로세스를 확인 후, 80포트를 다른 서비스에서 사용하는 것이 정상적인 상황이라면,

/etc/nginx/conf.d/default.conf 내의 80 포트를 다른 값 ex)8081 등으로 바꿔주면 된다.

(1.18에서는 conf.d 경로는 있지만 설정파일은 사용하지 않는다. 그래서 1.27 버전의 설정파일이 설치됨.)

server {
    listen       8081;
    server_name  localhost;

 

끝으로 확인해본다.

root@ubuntu:/etc/nginx# curl -I http://127.0.0.1:8081
HTTP/1.1 200 OK
Server: nginx/1.27.1
Date: Sun, 25 Aug 2024 01:21:04 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Mon, 12 Aug 2024 14:21:01 GMT
Connection: keep-alive
ETag: "66ba1a4d-267"
Accept-Ranges: bytes