<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Let's Encrypt | ITとガジェットあれこれ</title>
	<atom:link href="https://sandambara.com/category/lets-encrypt/feed" rel="self" type="application/rss+xml" />
	<link>https://sandambara.com</link>
	<description>sandambara.com</description>
	<lastBuildDate>Sun, 23 May 2021 06:21:54 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>

<image>
	<url>https://sandambara.com/wp-content/uploads/2021/03/icon.ico</url>
	<title>Let's Encrypt | ITとガジェットあれこれ</title>
	<link>https://sandambara.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>AWSにWordPressを構築する　2（SSL Let&#8217;s Encrypt設定）</title>
		<link>https://sandambara.com/wordpress-with-aws-2-using-letsencrypt?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wordpress-with-aws-2-using-letsencrypt</link>
					<comments>https://sandambara.com/wordpress-with-aws-2-using-letsencrypt#respond</comments>
		
		<dc:creator><![CDATA[sandambara]]></dc:creator>
		<pubDate>Wed, 26 May 2021 04:00:00 +0000</pubDate>
				<category><![CDATA[AWS]]></category>
		<category><![CDATA[Let's Encrypt]]></category>
		<category><![CDATA[Linux]]></category>
		<guid isPermaLink="false">https://sandambara.com/?p=1803</guid>

					<description><![CDATA[<p>AWS上のEC2をSSL化しWordPress構築をゴールとする記事。今回はLet&#8217;s EncryptでSSL化に挑戦します。 目次 この記事の趣旨ここまでの流れepelリポジトリ追加Certbotクライアン [&#8230;]</p>
The post <a href="https://sandambara.com/wordpress-with-aws-2-using-letsencrypt">AWSにWordPressを構築する　2（SSL Let’s Encrypt設定）</a> first appeared on <a href="https://sandambara.com">ITとガジェットあれこれ</a>.]]></description>
										<content:encoded><![CDATA[<p>AWS上のEC2をSSL化しWordPress構築をゴールとする記事。今回はLet&#8217;s EncryptでSSL化に挑戦します。</p>




  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">この記事の趣旨</a></li><li><a href="#toc2" tabindex="0">ここまでの流れ</a></li><li><a href="#toc3" tabindex="0">epelリポジトリ追加</a></li><li><a href="#toc4" tabindex="0">Certbotクライアントのインストール</a></li><li><a href="#toc5" tabindex="0">証明書作成</a></li><li><a href="#toc6" tabindex="0">ssl.conf作成</a></li><li><a href="#toc7" tabindex="0">httpd再起動</a></li><li><a href="#toc8" tabindex="0">index.html作成</a></li></ol>
    </div>
  </div>

<h2 class="wp-block-heading"><span id="toc1">この記事の趣旨</span></h2>



<p>自分が分からなかったこと・知らなかったことをググり倒した結果を備忘録として残すことが目的で、初学者の方に教え伝えるものではありません（きっぱり）。</p>



<p>誤認と思われる箇所は教えて頂ければうれしいです。</p>



<h2 class="wp-block-heading"><span id="toc2">ここまでの流れ</span></h2>



<p>EC2構築〜Route53の設定あたりまではこちらをご覧ください。</p>





<a href="https://sandambara.com/wordpress-with-aws-1" title="AWSにWordPressを構築する　1（EC2構築　Route53設定）" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img decoding="async" width="160" height="90" src="https://sandambara.com/wp-content/uploads/2021/05/スクリーンショット-2021-05-22-17.41.40-160x90.png" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://sandambara.com/wp-content/uploads/2021/05/スクリーンショット-2021-05-22-17.41.40-160x90.png 160w, https://sandambara.com/wp-content/uploads/2021/05/スクリーンショット-2021-05-22-17.41.40-120x68.png 120w, https://sandambara.com/wp-content/uploads/2021/05/スクリーンショット-2021-05-22-17.41.40-320x180.png 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">AWSにWordPressを構築する　1（EC2構築　Route53設定）</div><div class="blogcard-snippet internal-blogcard-snippet">今回はAWSに仮想マシンを作成し、独自ドメイン設定→SSL証明書(Let&#039;s Encrypt)を設定してWordPress構築を目指します。ドメインは取得済みの前提です。この記事の趣旨自分が分からなかったこと・知らなかったことをググり倒した...</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img decoding="async" src="https://www.google.com/s2/favicons?domain=https://sandambara.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">sandambara.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2021.05.24</div></div></div></div></a>




<h2 class="wp-block-heading"><span id="toc3">epelリポジトリ追加</span></h2>



<p>Amazon Linuxへepelリポジトリを追加します。</p>



<pre class="wp-block-code"><code>&#91;ec2-user@ip-172-31-11-12 ~]$ sudo amazon-linux-extras install epel
Installing epel-release
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Cleaning repos: amzn2-core amzn2extra-docker amzn2extra-epel
12 metadata files removed
4 sqlite files removed
0 metadata files removed
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                               

# 以下省略                                                                                                                </code></pre>



<h2 class="wp-block-heading"><span id="toc4">Certbotクライアントのインストール</span></h2>



<p>Let&#8217;s Encryptの証明書は90日間しかありません。この更新処理を自動で行ってくれるのがCertbotです。</p>



<pre class="wp-block-code"><code>&#91;ec2-user@ip-172-31-11-12 ~]$ sudo yum install certbot python-certbot-apache
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
219 packages excluded due to repository priority protections
Resolving Dependencies
--&gt; Running transaction check

# 以下省略</code></pre>



<h2 class="wp-block-heading"><span id="toc5">証明書作成</span></h2>



<p>Let&#8217;s Encryptの証明書を作成します。その前に/etc/httpd/conf/httpd.confのDocumentRootを下記のように変更し（sandambaraの箇所はお好みのディレクトリで）、.confで指定したディレクトリを作成します。</p>



<pre class="wp-block-code"><code>DocumentRoot "/var/www/html/sandambara"

Ctrl + x → y → Enterキーで保存して終了したら

sudo mkdir /var/www/html/sandambara</code></pre>



<p>【注意】<span class="marker-red">セキュリティグループでhttp・httpsが通るようにしておきましょう。</span></p>



<p>証明書発行コマンドの書式はこうです。</p>



<p><span class="marker-red">certbot certonly &#8211;webroot -w DocumentRootのディレクトリ -d SSLにしたいドメイン</span></p>



<p>コマンド入力後は下記要領で進みます。</p>



<ul class="wp-block-list"><li>連絡先メールアドレス</li><li>規約同意　→　y</li><li>メールのお知らせ　→　お好みに応じてお好きな方を（y or n)</li></ul>



<p>これが実際の流れです。</p>



<pre class="wp-block-code"><code>&#91;ec2-user@ip-172-31-11-12 ~]$ sudo certbot certonly --webroot -w /var/www/html/sandambara -d sandambara.work
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
Enter email address (used for urgent renewal and security notices)
 (Enter 'c' to cancel): 連絡先メールアドレス

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at

<a rel="noopener" href="https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf." title="Page not found" class="blogcard-wrap external-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img decoding="async" src="https://s.wordpress.com/mshots/v1/https%3A%2F%2Fletsencrypt.org%2Fdocuments%2FLE-SA-v1.2-November-15-2017.pdf.?w=160&#038;h=90" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">Page not found</div><div class="blogcard-snippet external-blogcard-snippet"></div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf." alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">letsencrypt.org</div></div></div></div></a> You must
agree in order to register with the ACME server. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: y

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, to
share your email address with the Electronic Frontier Foundation, a founding
partner of the Let's Encrypt project and the non-profit organization that
develops Certbot? We'd like to send you email about our work encrypting the web,
EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: n
Account registered.
Requesting a certificate for sandambara.work
Performing the following challenges:
http-01 challenge for sandambara.work
Using the webroot path /var/www/html/sandambara for all unmatched domains.
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/sandambara.work/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/sandambara.work/privkey.pem
   Your certificate will expire on 2021-08-20. To obtain a new or
   tweaked version of this certificate in the future, simply run
   certbot again. To non-interactively renew *all* of your
   certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

&#91;ec2-user@ip-172-31-11-12 ~]$ </code></pre>



<p>IMPORTANT NOTES:に続いて「Congratulations!」とあれば成功です。証明書が保存されているディレクトリは「/etc/letsencrypt/live/SSLにしたドメイン/」です。</p>



<pre class="wp-block-code"><code>&#91;ec2-user@ip-172-31-11-12 ~]$ sudo ls -l /etc/letsencrypt/live/sandambara.work/
total 4
lrwxrwxrwx 1 root root  39 May 22 12:40 cert.pem -&gt; ../../archive/sandambara.work/cert1.pem
lrwxrwxrwx 1 root root  40 May 22 12:40 chain.pem -&gt; ../../archive/sandambara.work/chain1.pem
lrwxrwxrwx 1 root root  44 May 22 12:40 fullchain.pem -&gt; ../../archive/sandambara.work/fullchain1.pem
lrwxrwxrwx 1 root root  42 May 22 12:40 privkey.pem -&gt; ../../archive/sandambara.work/privkey1.pem
-rw-r--r-- 1 root root 692 May 22 12:40 README</code></pre>



<h2 class="wp-block-heading"><span id="toc6">ssl.conf作成</span></h2>



<p>先ほど確認したディレクトリを/etc/httpd/conf.d/ssl.confへ書き込みます。</p>



<pre class="wp-block-code"><code>SLCertificateFile /etc/letsencrypt/live/sandambara.work/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/sandambara.work/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/sandambara.work/chain.pem     </code></pre>



<p>私の環境ではSSLCertificateChainFileだけデフォでコメントアウトされていました。</p>



<h2 class="wp-block-heading"><span id="toc7">httpd再起動</span></h2>



<pre class="wp-block-code"><code>sudo systemctl restart httpd</code></pre>



<pre class="wp-block-code"><code>sudo firewall-cmd --add-service=https --zone=public --permanent
sudo systemctl restart firewalld
sudo firewall-cmd --list-all          ←確認</code></pre>



<h2 class="wp-block-heading"><span id="toc8">index.html作成</span></h2>



<p>index.htmlを用意します。</p>



<pre class="wp-block-code"><code>sudo nano /var/www/html/sandambara/index.html</code></pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="334" height="206" src="https://sandambara.com/wp-content/uploads/2021/05/スクリーンショット-2021-05-22-22.20.12.png" alt="" class="wp-image-1805" srcset="https://sandambara.com/wp-content/uploads/2021/05/スクリーンショット-2021-05-22-22.20.12.png 334w, https://sandambara.com/wp-content/uploads/2021/05/スクリーンショット-2021-05-22-22.20.12-300x185.png 300w" sizes="(max-width: 334px) 100vw, 334px" /></figure>



<p>では、https://SSL化したドメインにアクセスしてみましょう！</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="606" height="246" src="https://sandambara.com/wp-content/uploads/2021/05/スクリーンショット-2021-05-22-22.16.30.png" alt="" class="wp-image-1804" srcset="https://sandambara.com/wp-content/uploads/2021/05/スクリーンショット-2021-05-22-22.16.30.png 606w, https://sandambara.com/wp-content/uploads/2021/05/スクリーンショット-2021-05-22-22.16.30-300x122.png 300w" sizes="(max-width: 606px) 100vw, 606px" /></figure>The post <a href="https://sandambara.com/wordpress-with-aws-2-using-letsencrypt">AWSにWordPressを構築する　2（SSL Let’s Encrypt設定）</a> first appeared on <a href="https://sandambara.com">ITとガジェットあれこれ</a>.]]></content:encoded>
					
					<wfw:commentRss>https://sandambara.com/wordpress-with-aws-2-using-letsencrypt/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
