【RHEL9.6】にyum/dnfコマンドでNGINXをインストールする

Linux

Red Hat Enterprise Linux 9.6に対してyum/dnfコマンドでNGINXをインストールした作業証跡をまとめました。

OSのバージョン確認

まずは以下のコマンドでOSのバージョンを確認します。

cat /etc/os-release

RHEL9.6であることを確認できます。

[root@RHEL96 ~]# cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="9.6 (Plow)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="9.6"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Red Hat Enterprise Linux 9.6 (Plow)"
ANSI_COLOR="0;31"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:redhat:enterprise_linux:9::baseos"
HOME_URL="https://www.redhat.com/"
DOCUMENTATION_URL="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9"
BUG_REPORT_URL="https://issues.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 9"
REDHAT_BUGZILLA_PRODUCT_VERSION=9.6
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.6"
[root@RHEL96 ~]#

yum / dnfコマンドでRHEL9.6にNGINXをインストールする

yumもしくはdnfコマンドでRHEL9.6にNGINXをインストールします。

今回はdnfコマンドでインストールを実施します。

dnf install nginx

実行した結果は以下です。

[root@RHEL96 ~]# dnf install nginx
サブスクリプション管理リポジトリーを更新しています。
メタデータの期限切れの最終確認: 3:08:41 前の 2025年10月11日 14時59分39秒 に実施しました。
依存関係が解決しました。
======================================================================================================================================================================
 パッケージ                             アーキテクチャー           バージョン                              リポジトリー                                         サイズ
======================================================================================================================================================================
インストール:
 nginx                                  x86_64                     2:1.20.1-22.el9_6.3                     rhel-9-for-x86_64-appstream-rpms                      37 k
依存関係のインストール:
 nginx-core                             x86_64                     2:1.20.1-22.el9_6.3                     rhel-9-for-x86_64-appstream-rpms                     571 k
 nginx-filesystem                       noarch                     2:1.20.1-22.el9_6.3                     rhel-9-for-x86_64-appstream-rpms                      10 k
 redhat-logos-httpd                     noarch                     90.5-1.el9_6.1                          rhel-9-for-x86_64-appstream-rpms                      16 k

トランザクションの概要
======================================================================================================================================================================
インストール  4 パッケージ

ダウンロードサイズの合計: 635 k
インストール後のサイズ: 1.8 M
これでよろしいですか? [y/N]:

yを入力してインストールをすすめます。

3回yを入力する場面があったので3回ともyを入力しエンターキーを押下しました。

[root@RHEL96 ~]# dnf install nginx
サブスクリプション管理リポジトリーを更新しています。
メタデータの期限切れの最終確認: 3:08:41 前の 2025年10月11日 14時59分39秒 に実施しました。
依存関係が解決しました。
======================================================================================================================================================================
 パッケージ                             アーキテクチャー           バージョン                              リポジトリー                                         サイズ
======================================================================================================================================================================
インストール:
 nginx                                  x86_64                     2:1.20.1-22.el9_6.3                     rhel-9-for-x86_64-appstream-rpms                      37 k
依存関係のインストール:
 nginx-core                             x86_64                     2:1.20.1-22.el9_6.3                     rhel-9-for-x86_64-appstream-rpms                     571 k
 nginx-filesystem                       noarch                     2:1.20.1-22.el9_6.3                     rhel-9-for-x86_64-appstream-rpms                      10 k
 redhat-logos-httpd                     noarch                     90.5-1.el9_6.1                          rhel-9-for-x86_64-appstream-rpms                      16 k

トランザクションの概要
======================================================================================================================================================================
インストール  4 パッケージ

ダウンロードサイズの合計: 635 k
インストール後のサイズ: 1.8 M
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
(1/4): nginx-1.20.1-22.el9_6.3.x86_64.rpm                                                                                              40 kB/s |  37 kB     00:00
(2/4): nginx-filesystem-1.20.1-22.el9_6.3.noarch.rpm                                                                                   11 kB/s |  10 kB     00:00
(3/4): nginx-core-1.20.1-22.el9_6.3.x86_64.rpm                                                                                        484 kB/s | 571 kB     00:01
(4/4): redhat-logos-httpd-90.5-1.el9_6.1.noarch.rpm                                                                                    61 kB/s |  16 kB     00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
合計                                                                                                                                  526 kB/s | 635 kB     00:01
Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)                                                                              1.7 MB/s | 3.6 kB     00:00
GPG 鍵 0xFD431D51 をインポート中:
 Userid     : "Red Hat, Inc. (release key 2) <security@redhat.com>"
 Fingerprint: 567E 347A D004 4ADE 55BA 8A5F 199E 2F91 FD43 1D51
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
これでよろしいですか? [y/N]: y
鍵のインポートに成功しました
GPG 鍵 0x5A6340B3 をインポート中:
 Userid     : "Red Hat, Inc. (auxiliary key 3) <security@redhat.com>"
 Fingerprint: 7E46 2425 8C40 6535 D56D 6F13 5054 E4A4 5A63 40B3
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
これでよろしいですか? [y/N]: y
鍵のインポートに成功しました
トランザクションを確認しています
トランザクションの確認に成功しました。
トランザクションをテストしています
トランザクションのテストに成功しました。
トランザクションを実行しています
  準備中           :                                                                                                                                              1/1
  scriptletの実行中: nginx-filesystem-2:1.20.1-22.el9_6.3.noarch                                                                                                  1/4
  インストール中   : nginx-filesystem-2:1.20.1-22.el9_6.3.noarch                                                                                                  1/4
  インストール中   : nginx-core-2:1.20.1-22.el9_6.3.x86_64                                                                                                        2/4
  インストール中   : redhat-logos-httpd-90.5-1.el9_6.1.noarch                                                                                                     3/4
  インストール中   : nginx-2:1.20.1-22.el9_6.3.x86_64                                                                                                             4/4
  scriptletの実行中: nginx-2:1.20.1-22.el9_6.3.x86_64                                                                                                             4/4
  検証中           : nginx-2:1.20.1-22.el9_6.3.x86_64                                                                                                             1/4
  検証中           : nginx-core-2:1.20.1-22.el9_6.3.x86_64                                                                                                        2/4
  検証中           : nginx-filesystem-2:1.20.1-22.el9_6.3.noarch                                                                                                  3/4
  検証中           : redhat-logos-httpd-90.5-1.el9_6.1.noarch                                                                                                     4/4
インストール済みの製品が更新されています。

インストール済み:
  nginx-2:1.20.1-22.el9_6.3.x86_64   nginx-core-2:1.20.1-22.el9_6.3.x86_64   nginx-filesystem-2:1.20.1-22.el9_6.3.noarch   redhat-logos-httpd-90.5-1.el9_6.1.noarch

完了しました!
[root@RHEL96 ~]#

インストールしたNGINXの設定ファイルの確認

catコマンドでインストールしたNGINXの設定ファイルに記載されている内容を確認します。

[root@RHEL96 ~]# cat /etc/nginx/nginx.conf
# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80;
        listen       [::]:80;
        server_name  _;
        root         /usr/share/nginx/html;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        error_page 404 /404.html;
        location = /404.html {
        }

        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
        }
    }

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2;
#        listen       [::]:443 ssl http2;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers PROFILE=SYSTEM;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}

[root@RHEL96 ~]#

上記の設定ファイルには以下のように書かれています。

    include /etc/nginx/conf.d/*.conf;

これは /etc/nginx/conf.d/ディレクトリ配下の.confファイルを参照していることを示します。デフォルトでは、/etc/nginx/conf.d/ディレクトリには特にconfファイルは格納されていないので、個別にconfファイルに追記したい内容があるときは、このディレクトリを活用することができます。

[root@RHEL96 conf.d]# pwd
/etc/nginx/conf.d
[root@RHEL96 conf.d]#
[root@RHEL96 conf.d]#
[root@RHEL96 conf.d]#
[root@RHEL96 conf.d]# ls -la
合計 4
drwxr-xr-x. 2 root root    6  5月 15 05:22 .
drwxr-xr-x. 4 root root 4096 10月 11 18:09 ..
[root@RHEL96 conf.d]#

タイトルとURLをコピーしました