Apache httpd 2.4.71(TLS1.3対応)+ HTTP/2 + Brotli インストールメモ

Linux
Linux
スポンサーリンク

2026年11月11日、Apache httpd 2.4.71 がリリースされました。Apache httpd 2.4.71 では、3件の脆弱性が修正されたほか、各種不具合の修正も行われています。特にCVE-2026-119618は、mod_http2のassign_headers()における排他制御の不備で、リモートコード実行(RCE)につながる可能性のある脆弱性です。Apache プロジェクトにより最も深刻度の高い「Critical」と評価されており、速やかなアップデートを強くお勧めします。そこで今回は、AlmaLinux 8、Rocky Linux 8、AlmaLinux 9、Rocky Linux 9、CentOS Stream 9、AlmaLinux 10、Rocky Linux 10、CentOS Stream 10 に Apache httpd 2.4.71 をインストールする手順をまとめてみました。

参考資料:Complete ChangeLog for 2.4

開発ツールのインストール

Apache httpd や各種ライブラリをソースからコンパイルしますので、パッケージを「最小限のインストール」でインストールしている場合は、基本パッケージと開発ツールをインストールしておきましょう。

dnf groupinstall base
dnf groupinstall development

パッケージのアップデート

インストール済みのパッケージを、最新版にアップデートします。

dnf update

OSを再起動します。

shutdown -r now

OpenSSL 3.5 のインストール(OSバージョン8のみ)

【注意】下記のバージョンのOSには標準で OpenSSL 3.5 がインストールされていますのでこの手順は不要です。
別にインストールした OpenSSL 3.5 のライブラリをパスに追加すると不具合が発生するケースがありますので、インストールしないように注意してください。

  • AlmaLinux 9
  • Rocky Linux 9
  • CentOS Stream 9
  • AlmaLinux 10
  • Rocky Linux 10
  • CentOS Stream 10

サーバOSが AlmaLinux 8、Rocky Linux 8 の場合は、OpenSSL 3.5 をインストールします。

OpenSSL のコンパイルに必要なパッケージをインストールしておきます。

dnf install zlib-devel
dnf install perl-core

OpenSSL 3.5 のダウンロード(ダウンロードの前に OpenSSL 3.5 の最新リリース を確認しておきましょう)

cd /usr/local/src/
wget https://github.com/openssl/openssl/releases/download/openssl-3.5.9/openssl-3.5.9.tar.gz

OpenSSL 3.5 のインストール

tar xvzf openssl-3.5.9.tar.gz
cd openssl-3.5.9/
./Configure --prefix=/usr/local/openssl-3.5.9 shared zlib
make
make test
make install

OpenSSL 3.5 のライブラリにパスを通しておきます。

echo /usr/local/openssl-3.5.9/lib64 > /etc/ld.so.conf.d/openssl.conf
ldconfig

OpenSSL 3.5 の動作確認(バージョンが表示されればOKです)

/usr/local/openssl-3.5.9/bin/openssl version

OpenSSL 3.5.9 29 Sep 2026 (Library: OpenSSL 3.5.9 29 Sep 2026)

Nghttp2 のインストール

HTTP/2(mod_http2)のコアエンジン Nghttp2 をインストールします。

Nghttp2 のダウンロード(ダウンロードの前に Nghttp2の最新リリース を確認しておきましょう)

cd /usr/local/src/
wget https://github.com/nghttp2/nghttp2/releases/download/v1.71.0/nghttp2-1.71.0.tar.gz

Nghttp2 のライブラリをコンパイルしてインストールします。

tar xvzf nghttp2-1.71.0.tar.gz
cd nghttp2-1.71.0/
 
./configure --enable-lib-only
 
make
make install

以上で HTTP/2 のライブラリ「libnghttp2」が /usr/local/lib/ 以下にインストールされましたので、ライブラリのパスに追加しておきます。

echo /usr/local/lib > /etc/ld.so.conf.d/usr-local-lib.conf
ldconfig

Brotli のインストール

Brotli のコンパイルに cmake を使いますので、インストールしておきます。

CMake のインストール

dnf install cmake

Brotli のインストール

Brotli のダウンロード(ダウンロードの前に Brotliの最新リリース を確認しておきましょう)

cd /usr/local/src/
wget https://github.com/google/brotli/archive/refs/tags/v1.2.1.tar.gz

Brotli をコンパイルしてインストールします。

tar xvzf v1.2.1.tar.gz
cd brotli-1.2.1/
mkdir out && cd out
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
cmake --build . --config Release --target install

Brotli のライブラリが /usr/local/lib64 以下にインストールされましたので、ライブラリのパスに追加しておきます。

echo /usr/local/lib64 > /etc/ld.so.conf.d/usr-local-lib64.conf
ldconfig

Apache httpd インストールの下準備

Apache httpd のコンパイルに必要なパッケージをインストールしておきます。

AlmaLinux8、RockyLinux8 AlmaLinux 9、Rocky Linux 9、CentOS Stream 9 の場合

dnf install pcre-devel
dnf install expat-devel

AlmaLinux 10、Rocky Linux 10、CentOS Stream 10 の場合

dnf install pcre2-devel
dnf install expat-devel

また、Apache 2.4系をソースコードからインストールする場合は、APR と APR-util が必要になりますので、インストールしておきます。

APR

cd /usr/local/src/
wget https://dlcdn.apache.org/apr/apr-1.7.6.tar.gz
tar xvzf apr-1.7.6.tar.gz
cd apr-1.7.6/
./configure
make
make install

APR-util

cd /usr/local/src/
wget https://dlcdn.apache.org/apr/apr-util-1.6.6.tar.gz
tar xvzf apr-util-1.6.6.tar.gz
cd apr-util-1.6.6/
./configure --with-apr=/usr/local/apr
make
make install

Apache httpd 2.4.71 のインストール

本題の Apache httpd のインストールです。

Apache httpd のソースコードのダウンロード

cd /usr/local/src/
wget https://dlcdn.apache.org/httpd/httpd-2.4.71.tar.gz

ダウンロードしたソースコードを解凍して、ディレクトリを移動します。

tar xvzf httpd-2.4.71.tar.gz
cd httpd-2.4.71/

AlmaLinux8、RockyLinux8 の場合

Apache httpd をインストールします。AlmaLinux8、RockyLinux8 の場合は、「--with-ssl」オプションで OpenSSL 3.5 のインストールディレクトリを指定します。

./configure \
--enable-http2 \
--enable-brotli \
--with-brotli=/usr/local/lib64 \
--enable-ssl \
--with-ssl=/usr/local/openssl-3.5.9 \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr \
--enable-so \
--enable-mods-shared=all \
--enable-mpms-shared=all
 
make
make install

AlmaLinux 9、Rocky Linux 9、CentOS Stream 9、 AlmaLinux 10、Rocky Linux 10、CentOS Stream 10 の場合

openssl-devel をインストールします。

dnf install openssl-devel

Apache httpd をインストールします。AlmaLinux 9、Rocky Linux 9、CentOS Stream 9、 AlmaLinux 10、Rocky Linux 10、CentOS Stream 10 の場合は「--with-ssl」オプションの指定は必要ありません。

./configure \
--enable-http2 \
--enable-brotli \
--with-brotli=/usr/local/lib64 \
--enable-ssl \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr \
--enable-so \
--enable-mods-shared=all \
--enable-mpms-shared=all
 
make
make install

以上で Apache が /usr/local/apache2/ 以下にインストールされました。続いてSSLサーバー証明書の作成と、Apacheの設定を行います。

自己署名のSSLサーバー証明書の作成

正規の認証局が発行したサーバー証明書を、無料で取得することもできます。よければご参照ください → Let's Encrypt サーバー証明書の取得と自動更新設定メモ

HTTP/2 および Brotli は HTTPS が必須になりますので Apache の設定の前に、SSLサーバー証明書を作成しておきます。

秘密鍵の作成

openssl ecparam -name prime256v1 -genkey -out server.key

SSLサーバー証明書の作成(有効期限30年)
-subjオプションで C(Country Name)に2文字の国名コード、CN(Common Name)にサイトのドメイン名(FQDN)を指定してください。

openssl req -new -x509 \
-days 10950 \
-key server.key \
-subj '/C=JP/CN=www.example.com' \
-out server.crt

秘密鍵とSSL証明書を移動

mv -i server.key /etc/pki/tls/private/
mv -i server.crt /etc/pki/tls/certs/

パーミッションを変更

chmod 600 /etc/pki/tls/private/server.key
chmod 600 /etc/pki/tls/certs/server.crt

SELinux を有効にしている場合は、秘密鍵とSSL証明書に正しいセキュリティコンテキストをつけておきましょう。(Apache httpd 起動時にエラーが発生することがあります)

restorecon /etc/pki/tls/private/server.key
restorecon /etc/pki/tls/certs/server.crt

Apache httpd の設定

ログの出力先を変更

mkdir /var/log/httpd
rm -rf /usr/local/apache2/logs/
ln -s /var/log/httpd /usr/local/apache2/logs

(補足)Linuxディストリビューションによっては logrotate の設定により /usr 以下に出力されたログがローテーションできないことがありますので /var/log/ 以下に出力することをオススメします。

オリジナルの設定ファイルをバックアップ

mv -i /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.conf.org
mv -i /usr/local/apache2/conf/extra/httpd-ssl.conf /usr/local/apache2/conf/extra/httpd-ssl.conf.org

・設定ファイルを作成します(コピペしてください)
vim /usr/local/apache2/conf/httpd.conf

vim /usr/local/apache2/conf/extra/httpd-ssl.conf

systemd ユニットファイルの作成

Apache httpd 用の systemd ユニットファイル(起動スクリプトのようなもの)を作成します。

vim /etc/systemd/system/httpd.service

[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
 
[Service]
Type=forking
ExecStart=/usr/local/apache2/bin/apachectl start
ExecReload=/usr/local/apache2/bin/apachectl graceful
ExecStop=/usr/local/apache2/bin/apachectl stop
 
[Install]
WantedBy=multi-user.target

作成したサービスファイルを systemd に反映

systemctl daemon-reload

systemd に反映されているか確認

systemctl list-unit-files | grep httpd

httpd.service    disabled    disabled    ←この表示があればOK

起動

systemctl start httpd

自動起動設定

systemctl enable httpd

firewalld設定

HTTP(80/tcp) と HTTPS(443/tcp) を開けておきます。

firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-port=443/tcp --permanent
firewall-cmd --reload

・確認
firewall-cmd --list-all

public (default, active)
interfaces: enp0s3 enp0s8
sources:
services: dhcpv6-client ssh
ports: 443/tcp 80/tcp ←この表示があればOK
(略)

ログのローテーション設定

・設定ファイルを作成します
vim /etc/logrotate.d/httpd

/var/log/httpd/*log {
    daily 
    missingok 
    dateext 
    rotate 365 
    create 640 daemon daemon
    sharedscripts 
    postrotate 
        /bin/systemctl reload httpd.service > /dev/null 2>&1 || true
    endscript 
}

・確認します
logrotate -v /etc/logrotate.d/httpd
-----(下記のような表示であればOKです)-----

reading config file /etc/logrotate.d/httpd
(略)
Handling 1 logs
 
rotating pattern: /var/log/httpd/*log after 1 days empty log files are rotated, (365 rotations), old logs are removed
considering log /var/log/httpd/access_log
(略)
considering log /var/log/httpd/error_log
(略)

以上です。設定お疲れ様でした!

この記事をシェアする
あぱーブログをフォローする
スポンサーリンク
スポンサーリンク

コメント

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