CentOS 8에 Nginx mainline 최신 버전 설치 (공식 repository)

CentOS 8에 Nginx mainline 최신 버전 설치 (공식 repository)

2022-10-05 last update

6 minutes reading centos8 nginx

소개



공식 repository를 사용하여 CentOS8에 Nginx mainline 최신 버전 설치
상위 기사 : Nginx의 다양한 설치 방법과 EOL 요약
참고 : nginx: Linux packages

지원



이 방법으로 도입했을 경우, nginx의 개발이 정지할 때까지 서포트된다고 생각된다.
특정 버전을 지정하지 않으면 mainline 최신 버전이 항상 제공되는 것으로 보입니다.

note


  • yum-utils도 넣는 편이 좋을지도 (본 LOG에서는 넣지 않는다)
  • sudo yum install yum-utils
    
  • 패키지명이 입고 있으므로 무리해 넣어 보았지만, 이것으로 맞는지 모른다
  • 이 도입 방법의 뒤에 yum update 하지만 OS 표준 버젼으로 덧쓰기되지 않는 모양
  • 깨끗한 설치 방법이 안내될 때까지 모습이 좋을 것 같다


  • LOG



    리포지토리 등록


    # vi /etc/yum.repos.d/nginx.repo
    

    /etc/yum.repos.d/nginx.repo
    [nginx-stable]
    name=nginx stable repo
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=https://nginx.org/keys/nginx_signing.key
    
    [nginx-mainline]
    name=nginx mainline repo
    baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
    gpgcheck=1
    enabled=1
    gpgkey=https://nginx.org/keys/nginx_signing.key
    

    설치


    # cat /etc/redhat-release
    CentOS Linux release 8.0.1905 (Core)
    
    # yum --disablerepo=AppStream install -y nginx
    ... 略
    

    nginx 시작/중지


    # systemctl start nginx
    # systemctl status nginx
    ● nginx.service - nginx - high performance web server
       Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
      Drop-In: /usr/lib/systemd/system/nginx.service.d
               mqphp-fpm.conf
       Active: active (running) since Thu 2019-09-26 07:38:43 EDT; 9s ago
         Docs: http://nginx.org/en/docs/
      Process: 31408 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
     Main PID: 31409 (nginx)
        Tasks: 2 (limit: 11109)
       Memory: 2.5M
       CGroup: /system.slice/nginx.service
               tq31409 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
               mq31410 nginx: worker process
    
    Sep 26 07:38:43 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
    Sep 26 07:38:43 localhost.localdomain systemd[1]: Started nginx - high performance web server.
    
    # systemctl stop nginx
    # systemctl status nginx
    ● nginx.service - nginx - high performance web server
       Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
      Drop-In: /usr/lib/systemd/system/nginx.service.d
               mqphp-fpm.conf
       Active: inactive (dead)
         Docs: http://nginx.org/en/docs/
    
    Sep 26 06:36:54 localhost.localdomain systemd[1]: Stopping The nginx HTTP and reverse proxy server...
    Sep 26 06:36:54 localhost.localdomain systemd[1]: Stopped The nginx HTTP and reverse proxy server.
    Sep 26 07:25:51 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
    Sep 26 07:25:51 localhost.localdomain systemd[1]: Started nginx - high performance web server.
    Sep 26 07:26:24 localhost.localdomain systemd[1]: Stopping nginx - high performance web server...
    Sep 26 07:26:24 localhost.localdomain systemd[1]: Stopped nginx - high performance web server.
    Sep 26 07:38:43 localhost.localdomain systemd[1]: Starting nginx - high performance web server...
    Sep 26 07:38:43 localhost.localdomain systemd[1]: Started nginx - high performance web server.
    Sep 26 07:39:09 localhost.localdomain systemd[1]: Stopping nginx - high performance web server...
    Sep 26 07:39:09 localhost.localdomain systemd[1]: Stopped nginx - high performance web server.
    

    nginx 자동 시작 설정/설정 해제


    # systemctl enable nginx
    Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
    
    # systemctl list-unit-files --type=service |grep nginx
    nginx-debug.service                         disabled
    nginx.service                               enabled
    
    # systemctl disable nginx
    Removed /etc/systemd/system/multi-user.target.wants/nginx.service.
    
    # systemctl list-unit-files --type=service |grep nginx
    nginx-debug.service                         disabled
    nginx.service                               disabled
    

    각종 확인


    # which nginx
    /usr/sbin/nginx
    
    # nginx -v
    nginx version: nginx/1.17.4
    
    # yum info nginx
    Last metadata expiration check: 0:01:50 ago on Thu 26 Sep 2019 07:38:28 AM EDT.
    Installed Packages
    Name         : nginx
    Epoch        : 1
    Version      : 1.17.4
    Release      : 1.el8.ngx
    Arch         : x86_64
    Size         : 2.9 M
    Source       : nginx-1.17.4-1.el8.ngx.src.rpm
    Repo         : @System
    From repo    : nginx-mainline
    Summary      : High performance web server
    URL          : http://nginx.org/
    License      : 2-clause BSD-like license
    Description  : nginx [engine x] is an HTTP and reverse proxy server, as well as
                 : a mail proxy server.