Ubuntu 26.04 の Apache で HTTPS を扱うには、証明書と秘密鍵を配置し、SSL モジュール、TLS 用 VirtualHost、暗号スイート設定を有効にします。
この記事では Apache の基本設定が終わっている前提で、TLS 終端として Apache を動かすための手動手順を整理します。内部環境では自己署名 CA の証明書を使う場面もあります。
前提を確認する
apache2 -v
systemctl status apache2 --no-pager
sudo apache2ctl -t証明書と秘密鍵を確認する
例では /etc/my-ssl 配下に配置済みの証明書を使います。秘密鍵は読み取り権限を絞ります。
sudo ls -l /etc/my-ssl/certs/example.local.crt
sudo ls -l /etc/my-ssl/private/example.local.key
sudo openssl x509 -in /etc/my-ssl/certs/example.local.crt -noout -subject -issuer -datesTLS 関連モジュールを有効化する
sudo a2enmod ssl
sudo a2enmod rewrite
sudo a2enmod headersTLS 暗号設定を配置する
sudo install -d -m 0755 -o root -g root /etc/apache2/https-custom-config.d
sudo tee /etc/apache2/https-custom-config.d/tls-cipher.conf >/dev/null <<'EOF'
SSLProtocol -All +TLSv1.2 +TLSv1.3
SSLCipherSuite ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-CHACHA20-POLY1305
SSLHonorCipherOrder On
EOFHTTPS VirtualHost を作成する
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName web01.example.local
ServerAdmin webmaster@example.local
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/my-ssl/certs/example.local.crt
SSLCertificateKeyFile /etc/my-ssl/private/example.local.key
IncludeOptional /etc/apache2/https-custom-config.d/*.conf
</VirtualHost>
</IfModule>サイトを有効化する
sudo tee /etc/apache2/sites-available/default-ssl.conf >/dev/null <<'EOF'
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName web01.example.local
ServerAdmin webmaster@example.local
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/my-ssl/certs/example.local.crt
SSLCertificateKeyFile /etc/my-ssl/private/example.local.key
IncludeOptional /etc/apache2/https-custom-config.d/*.conf
</VirtualHost>
</IfModule>
EOF
sudo a2ensite default-ssl設定を検証して反映する
sudo apache2ctl -t
sudo apache2ctl -S
sudo systemctl restart apache2HTTPS の動作確認をする
curl -k -I https://127.0.0.1/
openssl s_client -connect 127.0.0.1:443 -servername web01.example.local </dev/null | openssl x509 -noout -subject -issuer -datesまとめ
Apache の TLS 設定では、証明書と秘密鍵、SSL モジュール、HTTPS VirtualHost、暗号設定、構文確認をまとめて扱います。自己署名証明書を使う場合は、クライアント側の CA 信頼設定も合わせて考える必要があります。
Ubuntu 26.04 Apache TLS の設定



