EC2のapacheにSSL証明書を設定する。 IT by NHM - 2021-02-042021-05-25 いつものごとくamazonのドキュメント チュートリアル: Amazon Linux 2 に SSL/TLS を設定するhttps://docs.aws.amazon.com/ja_jp/AWSEC2/latest/UserGuide/SSL-on-amazon-linux-2.html ステップ 1: サーバーで TLS を有効にする apacheが必要らしいのでインストールする。80,443をセキュリティグループで空けておくこと。 sudo yum install -y httpd 有効になっているかの確認 sudo systemctl is-enabled httpd disabled 有効化 sudo systemctl start httpd && sudo systemctl enable httpd Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. インスタンスを最新にして、モジュールインストールする。 sudo yum update -y sudo yum install -y mod_ssl テスト用証明書を作成する。 cd /etc/pki/tls/certs sudo ./make-dummy-cert localhost.crt コメントアウトする。 vi /etc/httpd/conf.d/ssl.conf #SSLCertificateKeyFile /etc/pki/tls/private/localhost.key apache再起動 sudo systemctl restart httpd WEBブラウザでアクセスできることを確認する。Chromeだとページ表示できないかもしれないのでsafariやfirefox使おう。 epelインストール sudo amazon-linux-extras install epel -y 自動更新の設定をする。ついでにapache再起動も設定しておく。 cat /etc/crontab 39 1,13 * * * root certbot renew --no-self-upgrade * 3 * * * root systemctl restart httpd Certbot をインストールして実行する sudo wget -r --no-parent -A 'epel-release-*.rpm' http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/ sudo rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-*.rpm sudo yum-config-manager --enable epel* sudo yum repolist all /etc/httpd/conf/httpd.confの編集 sudo vi /etc/httpd/conf/httpd.conf Listen 80の後に追加 <VirtualHost *:80> DocumentRoot "/var/www/html" ServerName "example.com" ServerAlias "www.example.com" </VirtualHost> sudo systemctl restart httpd certbotのインストールと実行 sudo yum install -y certbot python2-certbot-apache sudo certbot Share on Facebook Share Share on TwitterTweet Share on Pinterest Share Share on LinkedIn Share Share on Digg Share Tags: apache / AWS / EC2 / Let'sEncrypt / SSL証明書