初期費用無料、月額990円から、高速・多機能・高安定レンタルサーバー『エックスサーバー』
SSL/TLSの設定の前に
https://qiita.com/sqoot610/items/e2a7b3ba8fa30df42d6f
を設定してください。
taisuke@ubuntuserver:~$ sudo vi /etc/apache2/sites-available/default-ssl.conf
#2行目 : 管理者アドレス変更
ServerAdmin ご自身のサーバーの管理者メールアドレス
#31,32行目 : [1] で取得した証明書に変更
SSLCertificateFile /etc/letsencrypt/live/ご自身のサーバーのドメイン名/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/ご自身のサーバーのドメイン名/privkey.pem
#41行目 : コメント解除して [1] で取得したチェインファイルに変更
SSLCertificateChainFile /etc/letsencrypt/live/ご自身のサーバーのドメイン名/chain.pem
taisuke@ubuntuserver:~$ sudo a2ensite default-ssl
Enabling site default-ssl.
To activate the new configuration, you need to run:
systemctl reload apache2
taisuke@ubuntuserver:~$ sudo a2enmod ssl
Considering dependency mime for ssl:
Module mime already enabled
Considering dependency socache_shmcb for ssl:
Enabling module socache_shmcb.
Enabling module ssl.
See /usr/share/doc/apache2/README.Debian.gz on how to configure SSL and create self-signed certificates.
To activate the new configuration, you need to run:
systemctl restart apache2
taisuke@ubuntuserver:~$ sudo systemctl restart apache2
taisuke@ubuntuserver:~$ sudo vi /etc/apache2/sites-available/virtual.host.conf
DocumentRoot /var/www/virtual.host
ServerName www.virtual.host
ServerAdmin webmaster@virtual.host
ErrorLog /var/log/apache2/virtual.host.error.log
CustomLog /var/log/apache2/virtual.host.access.log combined
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
taisuke@ubuntuserver:~$ sudo a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
systemctl restart apache2
taisuke@ubuntuserver:~$ sudo systemctl restart apache2
任意のクライアントコンピューターから Web ブラウザーでテストページに HTTPS でアクセスして、正常にページが表示されれば OK です。
初期費用無料、月額990円から、高速・多機能・高安定レンタルサーバー『エックスサーバー』
ubuntu 24.04 LTSで自宅サーバー構築(SSL/TLS の設定)
Last updated at Posted at 2024-08-13
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme