Red Hat Enterprise Linux 9.5でのApacheのインストールと設定方法をまとめました。
本記事は以下のRed Hat公式サイトを参考にしてます。
第1章 Apache HTTP Web サーバーの設定 | Red Hat Product Documentation
第1章 Apache HTTP Web サーバーの設定 | Red Hat Documentation
Red Hat NetworkにRHELを接続する
RHELをRed Hatに接続します。
# subscription-manager register
以下のようにusername とpasswordを指定することでもRHELをRHNに接続することができます。
# subscription-manager register --username=jo@example.com --password=MyKul22pwd
この作業を行うにはあらかじめRed Hatにアカウントを作成する必要があります。

The world's open source leader
Red Hat is the world’s leading provider of open source solutions, using a community-powered approach to provide reliable...
subscription-managerのチートシートです。
レポジトリが有効であることを確認する
次のいずれかのコマンドを実行してレポジトリが有効であることを確認する。
yum repolist all
dnf repolist all
デフォルトでは以下の二つのレポジトリが有効になっています。
Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)
Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)
dnf/yumコマンドでApache HTTP Serverをインストールする
まずは、httpd(Apache HTTP Server)のインストール状況を確認します。
[root@localhost ~]# systemctl status httpd
Unit httpd.service could not be found.
httpd.serviceがインストールされていないことがわかります。
rpmコマンドでhttpが入っていないことも確認してみます。
rpm -qa |sort | grep http
実行結果は以下です。
[root@localhost ~]# rpm -qa |sort | grep http
libnghttp2-1.43.0-6.el9.x86_64
httpの文字列が含まれるrpmパッケージはありますが、本件は今回インストール予定のものではありません。
dnfコマンドでインストールします。
dnf install httpd
[root@localhost ~]# dnf install httpd
サブスクリプション管理リポジトリーを更新しています。
メタデータの期限切れの最終確認: 0:17:45 前の 2025年03月28日 10時05分33秒 に実施しました。
依存関係が解決しました。
=============================================================================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
=============================================================================================================================================================
インストール:
httpd x86_64 2.4.62-1.el9_5.2 rhel-9-for-x86_64-appstream-rpms 51 k
依存関係のインストール:
apr x86_64 1.7.0-12.el9_3 rhel-9-for-x86_64-appstream-rpms 126 k
apr-util x86_64 1.6.1-23.el9 rhel-9-for-x86_64-appstream-rpms 97 k
apr-util-bdb x86_64 1.6.1-23.el9 rhel-9-for-x86_64-appstream-rpms 14 k
httpd-core x86_64 2.4.62-1.el9_5.2 rhel-9-for-x86_64-appstream-rpms 1.5 M
httpd-filesystem noarch 2.4.62-1.el9_5.2 rhel-9-for-x86_64-appstream-rpms 15 k
httpd-tools x86_64 2.4.62-1.el9_5.2 rhel-9-for-x86_64-appstream-rpms 86 k
redhat-logos-httpd noarch 90.4-2.el9 rhel-9-for-x86_64-appstream-rpms 18 k
弱い依存関係のインストール:
apr-util-openssl x86_64 1.6.1-23.el9 rhel-9-for-x86_64-appstream-rpms 17 k
mod_http2 x86_64 2.0.26-2.el9_4.1 rhel-9-for-x86_64-appstream-rpms 167 k
mod_lua x86_64 2.4.62-1.el9_5.2 rhel-9-for-x86_64-appstream-rpms 60 k
トランザクションの概要
=============================================================================================================================================================
インストール 11 パッケージ
ダウンロードサイズの合計: 2.2 M
インストール後のサイズ: 6.1 M
これでよろしいですか? [y/N]: y
パッケージのダウンロード:
(1/11): apr-util-bdb-1.6.1-23.el9.x86_64.rpm 27 kB/s | 14 kB 00:00
(2/11): apr-util-openssl-1.6.1-23.el9.x86_64.rpm 22 kB/s | 17 kB 00:00
(3/11): redhat-logos-httpd-90.4-2.el9.noarch.rpm 71 kB/s | 18 kB 00:00
(4/11): apr-1.7.0-12.el9_3.x86_64.rpm 398 kB/s | 126 kB 00:00
(5/11): apr-util-1.6.1-23.el9.x86_64.rpm 90 kB/s | 97 kB 00:01
(6/11): mod_http2-2.0.26-2.el9_4.1.x86_64.rpm 490 kB/s | 167 kB 00:00
(7/11): httpd-2.4.62-1.el9_5.2.x86_64.rpm 205 kB/s | 51 kB 00:00
(8/11): httpd-filesystem-2.4.62-1.el9_5.2.noarch.rpm 64 kB/s | 15 kB 00:00
(9/11): mod_lua-2.4.62-1.el9_5.2.x86_64.rpm 272 kB/s | 60 kB 00:00
(10/11): httpd-tools-2.4.62-1.el9_5.2.x86_64.rpm 204 kB/s | 86 kB 00:00
(11/11): httpd-core-2.4.62-1.el9_5.2.x86_64.rpm 1.8 MB/s | 1.5 MB 00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------
合計 1.1 MB/s | 2.2 MB 00:01
Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs) 3.5 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
インストール中 : apr-1.7.0-12.el9_3.x86_64 1/11
インストール中 : apr-util-bdb-1.6.1-23.el9.x86_64 2/11
インストール中 : apr-util-openssl-1.6.1-23.el9.x86_64 3/11
インストール中 : apr-util-1.6.1-23.el9.x86_64 4/11
インストール中 : httpd-tools-2.4.62-1.el9_5.2.x86_64 5/11
scriptletの実行中: httpd-filesystem-2.4.62-1.el9_5.2.noarch 6/11
インストール中 : httpd-filesystem-2.4.62-1.el9_5.2.noarch 6/11
インストール中 : httpd-core-2.4.62-1.el9_5.2.x86_64 7/11
インストール中 : mod_lua-2.4.62-1.el9_5.2.x86_64 8/11
インストール中 : redhat-logos-httpd-90.4-2.el9.noarch 9/11
インストール中 : mod_http2-2.0.26-2.el9_4.1.x86_64 10/11
インストール中 : httpd-2.4.62-1.el9_5.2.x86_64 11/11
scriptletの実行中: httpd-2.4.62-1.el9_5.2.x86_64 11/11
検証中 : apr-util-1.6.1-23.el9.x86_64 1/11
検証中 : apr-util-bdb-1.6.1-23.el9.x86_64 2/11
検証中 : apr-util-openssl-1.6.1-23.el9.x86_64 3/11
検証中 : redhat-logos-httpd-90.4-2.el9.noarch 4/11
検証中 : apr-1.7.0-12.el9_3.x86_64 5/11
検証中 : mod_http2-2.0.26-2.el9_4.1.x86_64 6/11
検証中 : httpd-2.4.62-1.el9_5.2.x86_64 7/11
検証中 : httpd-core-2.4.62-1.el9_5.2.x86_64 8/11
検証中 : httpd-filesystem-2.4.62-1.el9_5.2.noarch 9/11
検証中 : httpd-tools-2.4.62-1.el9_5.2.x86_64 10/11
検証中 : mod_lua-2.4.62-1.el9_5.2.x86_64 11/11
インストール済みの製品が更新されています。
インストール済み:
apr-1.7.0-12.el9_3.x86_64 apr-util-1.6.1-23.el9.x86_64 apr-util-bdb-1.6.1-23.el9.x86_64 apr-util-openssl-1.6.1-23.el9.x86_64
httpd-2.4.62-1.el9_5.2.x86_64 httpd-core-2.4.62-1.el9_5.2.x86_64 httpd-filesystem-2.4.62-1.el9_5.2.noarch httpd-tools-2.4.62-1.el9_5.2.x86_64
mod_http2-2.0.26-2.el9_4.1.x86_64 mod_lua-2.4.62-1.el9_5.2.x86_64 redhat-logos-httpd-90.4-2.el9.noarch
完了しました!
インストールされました。
再びrpmパッケージとsystemctl status httpdの実行結果を確認します。
[root@localhost ~]# rpm -qa |sort | grep http
httpd-2.4.62-1.el9_5.2.x86_64
httpd-core-2.4.62-1.el9_5.2.x86_64
httpd-filesystem-2.4.62-1.el9_5.2.noarch
httpd-tools-2.4.62-1.el9_5.2.x86_64
libnghttp2-1.43.0-6.el9.x86_64
mod_http2-2.0.26-2.el9_4.1.x86_64
redhat-logos-httpd-90.4-2.el9.noarch
[root@localhost ~]# systemctl status httpd
○ httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; preset: disabled)
Active: inactive (dead)
Docs: man:httpd.service(8)
※インストール時の依存関係があるので、grep httpだけで確認するのではなく、rpm -qaで全量を確認したほうがよかったかもしれません。
Apache HTTP Serverを起動する
以下のコマンドでApacheを起動します。
# systemctl start httpd
上記コマンドの実行結果です。
[root@localhost ~]# systemctl start httpd
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; preset: disabled)
Active: active (running) since Fri 2025-03-28 10:27:07 JST; 4s ago
Docs: man:httpd.service(8)
Main PID: 34008 (httpd)
Status: "Started, listening on: port 80"
Tasks: 177 (limit: 10735)
Memory: 31.9M
CPU: 60ms
CGroup: /system.slice/httpd.service
tq34008 /usr/sbin/httpd -DFOREGROUND
tq34010 /usr/sbin/httpd -DFOREGROUND
tq34011 /usr/sbin/httpd -DFOREGROUND
tq34012 /usr/sbin/httpd -DFOREGROUND
mq34013 /usr/sbin/httpd -DFOREGROUND
3月 28 10:27:07 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
3月 28 10:27:07 localhost.localdomain httpd[34008]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.>
3月 28 10:27:07 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
3月 28 10:27:07 localhost.localdomain httpd[34008]: Server configured, listening on: port 80
再起動してもApache HTTP Serverが自動起動するようにする
OSが再起動してもApacheが自動で起動するように設定します。
# systemctl enable httpd
上記コマンドの実行結果です。
[root@localhost ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: disabled)
Active: active (running) since Fri 2025-03-28 10:27:07 JST; 27s ago
Docs: man:httpd.service(8)
Main PID: 34008 (httpd)
Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec: 0 B/sec"
Tasks: 177 (limit: 10735)
Memory: 31.9M
CPU: 95ms
CGroup: /system.slice/httpd.service
tq34008 /usr/sbin/httpd -DFOREGROUND
tq34010 /usr/sbin/httpd -DFOREGROUND
tq34011 /usr/sbin/httpd -DFOREGROUND
tq34012 /usr/sbin/httpd -DFOREGROUND
mq34013 /usr/sbin/httpd -DFOREGROUND
3月 28 10:27:07 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
3月 28 10:27:07 localhost.localdomain httpd[34008]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.>
3月 28 10:27:07 localhost.localdomain systemd[1]: Started The Apache HTTP Server.
3月 28 10:27:07 localhost.localdomain httpd[34008]: Server configured, listening on: port 80