以下の内容はhttps://souiunogaii.hatenablog.com/entry/almalinux96-apache24-installより取得しました。


AlmaLinux9.6にApache2.4をインストールする手順

※[PR]当ブログの記事の中にはプロモーションが含まれています。

・AlmaLinux9.6にApache2.4をインストールする方法を知りたい。
・具体的な手順を分かりやすく教えてほしい。

こういった疑問に答えます。

本記事の内容

  1. AlmaLinux9.6にApache2.4をインストールする手順

サトナカ (@souiunogaii)

この記事を書いている私は、某SIerに勤務しながら、
WEB系エンジニア・インフラエンジニアに憧れて、プログラミングおよびインフラ技術の勉強をしています。

こういった私が、解説していきます。

私が実機で試したコマンドや画像を載せて書いています。
記事の信頼性担保に繋がると思います。

AlmaLinux9.6にApache2.4をインストールする手順

パッケージの事前確認

[root@a-webap01 ~]# dnf list | grep httpd
almalinux-logos-httpd.noarch                         90.6-2.el9                          appstream
httpd.x86_64                                         2.4.62-4.el9                        appstream
httpd-core.x86_64                                    2.4.62-4.el9                        appstream
httpd-devel.x86_64                                   2.4.62-4.el9                        appstream
httpd-filesystem.noarch                              2.4.62-4.el9                        appstream
httpd-manual.noarch                                  2.4.62-4.el9                        appstream
httpd-tools.x86_64                                   2.4.62-4.el9                        appstream
keycloak-httpd-client-install.noarch                 1.3-1.el9                           appstream
libmicrohttpd.i686                                   1:0.9.72-5.el9                      appstream
libmicrohttpd.x86_64                                 1:0.9.72-5.el9                      appstream
python3-keycloak-httpd-client-install.noarch         1.3-1.el9                           appstream

Apache2.4インストール

dnf install httpd httpd-tools httpd-devel httpd-manual -y
[root@a-webap01 ~]# dnf install httpd httpd-tools httpd-devel httpd-manual -y
メタデータの期限切れの最終確認: 0:01:00 前の 20250901172540秒 に実施しました。
依存関係が解決しました。
====================================================================================================
 パッケージ                     Arch            バージョン                 リポジトリー       サイズ
====================================================================================================
インストール:
 httpd                          x86_64          2.4.62-4.el9               appstream           45 k
 httpd-devel                    x86_64          2.4.62-4.el9               appstream          192 k
 httpd-manual                   noarch          2.4.62-4.el9               appstream          2.2 M
 httpd-tools                    x86_64          2.4.62-4.el9               appstream           79 k
依存関係のインストール:
 almalinux-logos-httpd          noarch          90.6-2.el9                 appstream           18 k
 apr                            x86_64          1.7.0-12.el9_3             appstream          122 k
 apr-devel                      x86_64          1.7.0-12.el9_3             appstream          218 k
 apr-util                       x86_64          1.6.1-23.el9               appstream           94 k
 apr-util-bdb                   x86_64          1.6.1-23.el9               appstream           12 k
 apr-util-devel                 x86_64          1.6.1-23.el9               appstream           70 k
 cyrus-sasl                     x86_64          2.1.27-21.el9              baseos              71 k
 cyrus-sasl-devel               x86_64          2.1.27-21.el9              appstream          102 k
 expat-devel                    x86_64          2.5.0-5.el9_6              appstream           51 k
 httpd-core                     x86_64          2.4.62-4.el9               appstream          1.4 M
 httpd-filesystem               noarch          2.4.62-4.el9               appstream           12 k
 libdb-devel                    x86_64          5.3.28-57.el9_6            appstream           36 k
 openldap-devel                 x86_64          2.6.8-4.el9                appstream          684 k
弱い依存関係のインストール:
 apr-util-openssl               x86_64          1.6.1-23.el9               appstream           14 k
 mod_http2                      x86_64          2.0.26-4.el9               appstream          163 k
 mod_lua                        x86_64          2.4.62-4.el9               appstream           58 k

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

ダウンロードサイズの合計: 5.6 M
インストール後のサイズ: 20 M
パッケージのダウンロード:
(1/20): almalinux-logos-httpd-90.6-2.el9.noarch.rpm                  11 kB/s |  18 kB     00:01
(2/20): apr-1.7.0-12.el9_3.x86_64.rpm                                74 kB/s | 122 kB     00:01
(3/20): apr-devel-1.7.0-12.el9_3.x86_64.rpm                         133 kB/s | 218 kB     00:01
(4/20): apr-util-1.6.1-23.el9.x86_64.rpm                            1.7 MB/s |  94 kB     00:00
(5/20): apr-util-bdb-1.6.1-23.el9.x86_64.rpm                        351 kB/s |  12 kB     00:00
(6/20): apr-util-devel-1.6.1-23.el9.x86_64.rpm                      1.7 MB/s |  70 kB     00:00
(7/20): apr-util-openssl-1.6.1-23.el9.x86_64.rpm                    408 kB/s |  14 kB     00:00
(8/20): cyrus-sasl-devel-2.1.27-21.el9.x86_64.rpm                   2.3 MB/s | 102 kB     00:00
(9/20): expat-devel-2.5.0-5.el9_6.x86_64.rpm                        1.3 MB/s |  51 kB     00:00
(10/20): httpd-2.4.62-4.el9.x86_64.rpm                              1.1 MB/s |  45 kB     00:00
(11/20): httpd-filesystem-2.4.62-4.el9.noarch.rpm                   230 kB/s |  12 kB     00:00
(12/20): httpd-devel-2.4.62-4.el9.x86_64.rpm                        1.8 MB/s | 192 kB     00:00
(13/20): httpd-core-2.4.62-4.el9.x86_64.rpm                         4.9 MB/s | 1.4 MB     00:00
(14/20): httpd-tools-2.4.62-4.el9.x86_64.rpm                        450 kB/s |  79 kB     00:00
(15/20): libdb-devel-5.3.28-57.el9_6.x86_64.rpm                     985 kB/s |  36 kB     00:00
(16/20): mod_http2-2.0.26-4.el9.x86_64.rpm                          2.2 MB/s | 163 kB     00:00
(17/20): mod_lua-2.4.62-4.el9.x86_64.rpm                            1.2 MB/s |  58 kB     00:00
(18/20): cyrus-sasl-2.1.27-21.el9.x86_64.rpm                        1.4 MB/s |  71 kB     00:00
(19/20): httpd-manual-2.4.62-4.el9.noarch.rpm                       4.6 MB/s | 2.2 MB     00:00
(20/20): openldap-devel-2.6.8-4.el9.x86_64.rpm                      3.5 MB/s | 684 kB     00:00
----------------------------------------------------------------------------------------------------
合計                                                                1.6 MB/s | 5.6 MB     00:03
トランザクションを確認しています
トランザクションの確認に成功しました。
トランザクションをテストしています
トランザクションのテストに成功しました。
トランザクションを実行しています
  準備中           :                                                                            1/1
  インストール中   : apr-1.7.0-12.el9_3.x86_64                                                 1/20
  インストール中   : apr-util-bdb-1.6.1-23.el9.x86_64                                          2/20
  インストール中   : apr-util-openssl-1.6.1-23.el9.x86_64                                      3/20
  インストール中   : apr-util-1.6.1-23.el9.x86_64                                              4/20
  インストール中   : apr-devel-1.7.0-12.el9_3.x86_64                                           5/20
  インストール中   : httpd-tools-2.4.62-4.el9.x86_64                                           6/20
  scriptletの実行中: cyrus-sasl-2.1.27-21.el9.x86_64                                           7/20
  インストール中   : cyrus-sasl-2.1.27-21.el9.x86_64                                           7/20
  scriptletの実行中: cyrus-sasl-2.1.27-21.el9.x86_64                                           7/20
  インストール中   : cyrus-sasl-devel-2.1.27-21.el9.x86_64                                     8/20
  インストール中   : openldap-devel-2.6.8-4.el9.x86_64                                         9/20
  インストール中   : libdb-devel-5.3.28-57.el9_6.x86_64                                       10/20
  scriptletの実行中: httpd-filesystem-2.4.62-4.el9.noarch                                     11/20
  インストール中   : httpd-filesystem-2.4.62-4.el9.noarch                                     11/20
  インストール中   : httpd-core-2.4.62-4.el9.x86_64                                           12/20
  インストール中   : mod_lua-2.4.62-4.el9.x86_64                                              13/20
  インストール中   : expat-devel-2.5.0-5.el9_6.x86_64                                         14/20
  インストール中   : apr-util-devel-1.6.1-23.el9.x86_64                                       15/20
  インストール中   : almalinux-logos-httpd-90.6-2.el9.noarch                                  16/20
  インストール中   : mod_http2-2.0.26-4.el9.x86_64                                            17/20
  インストール中   : httpd-2.4.62-4.el9.x86_64                                                18/20
  scriptletの実行中: httpd-2.4.62-4.el9.x86_64                                                18/20
  インストール中   : httpd-devel-2.4.62-4.el9.x86_64                                          19/20
  インストール中   : httpd-manual-2.4.62-4.el9.noarch                                         20/20
  scriptletの実行中: httpd-2.4.62-4.el9.x86_64                                                20/20
  scriptletの実行中: httpd-manual-2.4.62-4.el9.noarch                                         20/20
  検証中           : almalinux-logos-httpd-90.6-2.el9.noarch                                   1/20
  検証中           : apr-1.7.0-12.el9_3.x86_64                                                 2/20
  検証中           : apr-devel-1.7.0-12.el9_3.x86_64                                           3/20
  検証中           : apr-util-1.6.1-23.el9.x86_64                                              4/20
  検証中           : apr-util-bdb-1.6.1-23.el9.x86_64                                          5/20
  検証中           : apr-util-devel-1.6.1-23.el9.x86_64                                        6/20
  検証中           : apr-util-openssl-1.6.1-23.el9.x86_64                                      7/20
  検証中           : cyrus-sasl-devel-2.1.27-21.el9.x86_64                                     8/20
  検証中           : expat-devel-2.5.0-5.el9_6.x86_64                                          9/20
  検証中           : httpd-2.4.62-4.el9.x86_64                                                10/20
  検証中           : httpd-core-2.4.62-4.el9.x86_64                                           11/20
  検証中           : httpd-devel-2.4.62-4.el9.x86_64                                          12/20
  検証中           : httpd-filesystem-2.4.62-4.el9.noarch                                     13/20
  検証中           : httpd-manual-2.4.62-4.el9.noarch                                         14/20
  検証中           : httpd-tools-2.4.62-4.el9.x86_64                                          15/20
  検証中           : libdb-devel-5.3.28-57.el9_6.x86_64                                       16/20
  検証中           : mod_http2-2.0.26-4.el9.x86_64                                            17/20
  検証中           : mod_lua-2.4.62-4.el9.x86_64                                              18/20
  検証中           : openldap-devel-2.6.8-4.el9.x86_64                                        19/20
  検証中           : cyrus-sasl-2.1.27-21.el9.x86_64                                          20/20

インストール済み:
  almalinux-logos-httpd-90.6-2.el9.noarch            apr-1.7.0-12.el9_3.x86_64
  apr-devel-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-devel-1.6.1-23.el9.x86_64
  apr-util-openssl-1.6.1-23.el9.x86_64               cyrus-sasl-2.1.27-21.el9.x86_64
  cyrus-sasl-devel-2.1.27-21.el9.x86_64              expat-devel-2.5.0-5.el9_6.x86_64
  httpd-2.4.62-4.el9.x86_64                          httpd-core-2.4.62-4.el9.x86_64
  httpd-devel-2.4.62-4.el9.x86_64                    httpd-filesystem-2.4.62-4.el9.noarch
  httpd-manual-2.4.62-4.el9.noarch                   httpd-tools-2.4.62-4.el9.x86_64
  libdb-devel-5.3.28-57.el9_6.x86_64                 mod_http2-2.0.26-4.el9.x86_64
  mod_lua-2.4.62-4.el9.x86_64                        openldap-devel-2.6.8-4.el9.x86_64

完了しました!

確認

[root@a-webap01 ~]# dnf list installed | grep httpd
almalinux-logos-httpd.noarch                   90.6-2.el9                       @appstream
httpd.x86_64                                   2.4.62-4.el9                     @appstream
httpd-core.x86_64                              2.4.62-4.el9                     @appstream
httpd-devel.x86_64                             2.4.62-4.el9                     @appstream
httpd-filesystem.noarch                        2.4.62-4.el9                     @appstream
httpd-manual.noarch                            2.4.62-4.el9                     @appstream
httpd-tools.x86_64                             2.4.62-4.el9                     @appstream
[root@a-webap01 ~]# which httpd
/usr/sbin/httpd

httpdサービス起動

systemctl start httpd
[root@a-webap01 ~]# systemctl start httpd
[root@a-webap01 ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; preset: disabled)
     Active: active (running) since Mon 2025-09-01 17:28:00 JST; 4s ago
       Docs: man:httpd.service(8)
   Main PID: 3598 (httpd)
     Status: "Started, listening on: port 80"
      Tasks: 177 (limit: 11066)
     Memory: 34.2M
        CPU: 58ms
     CGroup: /system.slice/httpd.service
             tq3598 /usr/sbin/httpd -DFOREGROUND
             tq3599 /usr/sbin/httpd -DFOREGROUND
             tq3600 /usr/sbin/httpd -DFOREGROUND
             tq3601 /usr/sbin/httpd -DFOREGROUND
             mq3602 /usr/sbin/httpd -DFOREGROUND

 901 17:28:00 a-webap01 systemd[1]: Starting The Apache HTTP Server...
 901 17:28:00 a-webap01 systemd[1]: Started The Apache HTTP Server.
 901 17:28:00 a-webap01 httpd[3598]: Server configured, listening on: port 80

確認

[root@a-webap01 ~]# ps -aux | grep httpd
root        3598  0.1  0.6  20944 11596 ?        Ss   17:28   0:00 /usr/sbin/httpd -DFOREGROUND
apache      3599  0.0  0.4  22784  7400 ?        S    17:28   0:00 /usr/sbin/httpd -DFOREGROUND
apache      3600  0.0  0.8 982204 15320 ?        Sl   17:28   0:00 /usr/sbin/httpd -DFOREGROUND
apache      3601  0.0  0.9 1113340 17568 ?       Sl   17:28   0:00 /usr/sbin/httpd -DFOREGROUND
apache      3602  0.0  0.8 982204 15320 ?        Sl   17:28   0:00 /usr/sbin/httpd -DFOREGROUND
root        3781  0.0  0.1   4592  2304 pts/0    S+   17:28   0:00 grep --color=auto httpd

自動起動の設定

[root@a-webap01 ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@a-webap01 ~]# systemctl is-enabled httpd
enabled

firewalldの設定

[root@a-webap01 ~]# firewall-cmd --zone=home --add-service=http --permanent
success
[root@a-webap01 ~]# firewall-cmd --reload
success

ブラウザで表示確認

confの設定変更

/etc/httpd/conf/httpd.conf
     87 # ServerAdmin: Your address, where problems with the server should be
     88 # e-mailed.  This address appears on some server-generated pages, such
     89 # as error documents.  e.g. admin@your-domain.com
     90 #
     91 ServerAdmin root@blue-planet.internal  ←★★★変更

  (中略)

     94 # ServerName gives the name and port that the server uses to identify itself.
     95 # This can often be determined automatically, but we recommend you specify
     96 # it explicitly to prevent problems during startup.
     97 #
     98 # If your host doesn't have a registered DNS name, enter its IP address here.
     99 #
    100 ServerName a-webap01.blue-planet.internal:80  ←★★★変更
 
  (中略)
 
    144     #
    145     # The Options directive is both complicated and important.  Please see
    146     # http://httpd.apache.org/docs/2.4/mod/core.html#options
    147     # for more information.
    148     #
    149     Options FollowSymLinks  ←★★★変更

  (中略)

    245    # ScriptAlias: This controls which directories contain server scripts. 
    246    # ScriptAliases are essentially the same as Aliases, except that
    247    # documents in the target directory are treated as applications and
    248    # run by the server when requested rather than as documents sent to the
    249    # client.  The same rules about trailing "/" apply to ScriptAlias
    250    # directives as to Alias.
    251    #
    252    ScriptAlias /cgi-bin/ "/home/www/cgi-bin/"  ←★★★変更

  (中略)

    257 # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
    258 # CGI directory exists, if you have that configured.
    259 #
    260 <Directory "/home/www/cgi-bin">  ←★★★変更
    261     AllowOverride None
    262     Options None
    263     Require all granted
    264 </Directory>

確認

[root@a-webap01 ~]# httpd -t
Syntax OK

使用しないファイルのリネーム

[root@a-webap01 ~]# mv /etc/httpd/conf.d/autoindex.conf /etc/httpd/conf.d/autoindex.conf_original
[root@a-webap01 ~]# mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf_original

httpd再起動して変更を反映

[root@a-webap01 ~]# systemctl restart httpd

テストページを作成して表示確認

[root@a-webap01 ~]# vi /var/www/html/index.html

やったぜ!




以上の内容はhttps://souiunogaii.hatenablog.com/entry/almalinux96-apache24-installより取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14