<?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>HTTPS &#8211; 良的世界</title>
	<atom:link href="https://www.lemonary.cn/tag/https/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lemonary.cn</link>
	<description></description>
	<lastBuildDate>Tue, 03 Jun 2025 08:06:13 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.lemonary.cn/wp-content/uploads/2024/12/profile-150x150.jpg</url>
	<title>HTTPS &#8211; 良的世界</title>
	<link>https://www.lemonary.cn</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>网站SSL证书过期替换手册</title>
		<link>https://www.lemonary.cn/%e7%bd%91%e7%ab%99ssl%e8%af%81%e4%b9%a6%e8%bf%87%e6%9c%9f%e6%9b%bf%e6%8d%a2%e6%89%8b%e5%86%8c/</link>
					<comments>https://www.lemonary.cn/%e7%bd%91%e7%ab%99ssl%e8%af%81%e4%b9%a6%e8%bf%87%e6%9c%9f%e6%9b%bf%e6%8d%a2%e6%89%8b%e5%86%8c/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Tue, 03 Jun 2025 02:19:44 +0000</pubDate>
				<category><![CDATA[建站记录]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[SSL]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1903</guid>

					<description><![CDATA[一、前言 本站使用的是FreeSSL网站提供的免费证书，由于证书的有效期是三个月，所以每三个月就需要替换一次新 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">一、前言</h2>



<p class="wp-block-paragraph">本站使用的是FreeSSL网站提供的免费证书，由于证书的有效期是三个月，所以每三个月就需要替换一次新的证书。因此，特此记录下替换证书的整个过程，以便后续替换时参考。</p>



<h2 class="wp-block-heading">二、替换步骤</h2>



<h3 class="wp-block-heading">2.1 申请证书</h3>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-1024x549.png" alt="" class="wp-image-1905" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-2048x1098.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">选择单域名类型即可</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-1-1024x549.png" alt="" class="wp-image-1906" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-1-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-1-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-1-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-1-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-1-2048x1098.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">填写证书域名，点击提交</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-2-1024x549.png" alt="" class="wp-image-1907" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-2-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-2-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-2-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-2-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-2-2048x1098.png 2048w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">此时会跳转到KeyManager，若此前并未安装直接选择下载安装，然后同样跳转到KeyManager，此时KeyManager会弹出如下窗口</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="640" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-3-1024x640.png" alt="" class="wp-image-1908" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-3-1024x640.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-3-300x187.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-3-768x480.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-3-1536x960.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-3-2048x1280.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">2.2 添加DNS解析</h3>



<p class="wp-block-paragraph">然后返回浏览器继续操作，点击继续，然后会弹出如下窗口</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-5-1024x549.png" alt="" class="wp-image-1910" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-5-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-5-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-5-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-5-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-5-2048x1098.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">这是一条DNS解析，将此条解析添加到服务器域名的解析列表中（我的域名注册于华为云平台），按上述图片内容配置红框位置后，确认，完成添加。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-6-1024x549.png" alt="" class="wp-image-1911" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-6-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-6-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-6-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-6-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-6-2048x1098.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">再回到FREESSL，点击我已配置完成后回到订单列表可以看到刚刚申请的证书</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="217" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-7-1024x217.png" alt="" class="wp-image-1912" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-7-1024x217.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-7-300x64.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-7-768x163.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-7-1536x325.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-7-2048x434.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">点击验证，进行验证刚刚添加的DNS解析，验证成功后如下</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="250" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-9-1024x250.png" alt="" class="wp-image-1914" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-9-1024x250.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-9-300x73.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-9-768x188.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-9-1536x375.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-9-2048x500.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">2.3 KeyManager一键部署</h3>



<p class="wp-block-paragraph">点击保存到KeyManager，便可将证书保存到客户端软件，后续便可一键部署</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="668" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-10-1024x668.png" alt="" class="wp-image-1915" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-10-1024x668.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-10-300x196.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-10-768x501.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-10-1536x1002.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-10.png 1725w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">一键部署前需要配置部署信息，选择服务器类型，用户名、主机名、端口、证书存放路径、私钥存放路径、重载命令、服务器密码</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="780" height="840" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-11.png" alt="" class="wp-image-1916" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-11.png 780w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-11-279x300.png 279w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-11-768x827.png 768w" sizes="auto, (max-width: 780px) 100vw, 780px" /></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="778" height="840" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-12.png" alt="" class="wp-image-1917" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-12.png 778w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-12-278x300.png 278w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-12-768x829.png 768w" sizes="auto, (max-width: 778px) 100vw, 778px" /></figure>



<p class="wp-block-paragraph">配置完成后便可进行一键部署，刷新网页查看证书信息是否生效</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="817" height="1008" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-13.png" alt="" class="wp-image-1918" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-13.png 817w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-13-243x300.png 243w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-13-768x948.png 768w" sizes="auto, (max-width: 817px) 100vw, 817px" /></figure>



<p class="wp-block-paragraph">至此，证书替换完成。</p>



<h2 class="wp-block-heading">三、自动化管理</h2>



<p class="wp-block-paragraph">FreeSSL网站提供了自动化管理功能</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-14-1024x549.png" alt="" class="wp-image-1921" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-14-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-14-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-14-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-14-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-14-2048x1098.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">3.1 域名预授权</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="587" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-15-1024x587.png" alt="" class="wp-image-1922" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-15-1024x587.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-15-300x172.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-15-768x440.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-15.png 1044w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="917" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-16-1024x917.png" alt="" class="wp-image-1923" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-16-1024x917.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-16-300x269.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-16-768x688.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-16.png 1042w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">同样配置好DNS解析（这个过程参考上边）后点击配置完成，立即检测，验证通过后如下</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="549" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-17-1024x549.png" alt="" class="wp-image-1924" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-17-1024x549.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-17-300x161.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-17-768x412.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-17-1536x823.png 1536w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-17-2048x1098.png 2048w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">3.2 申请证书</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="512" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-18-1024x512.png" alt="" class="wp-image-1925" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-18-1024x512.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-18-300x150.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-18-768x384.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-18.png 1101w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">3.3 设置参数</h3>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="514" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-19-1024x514.png" alt="" class="wp-image-1926" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-19-1024x514.png 1024w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-19-300x151.png 300w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-19-768x385.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-19.png 1102w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">/usr/local/nginx/ssl/full_chain.pem<br>/usr/local/nginx/ssl/private.key</p>



<h3 class="wp-block-heading">3.4 客户端部署</h3>



<p class="wp-block-paragraph">最后会显示安装部署客户端的步骤，依次执行</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="802" height="1024" src="https://www.lemonary.cn/wp-content/uploads/2025/06/image-20-802x1024.png" alt="" class="wp-image-1927" srcset="https://www.lemonary.cn/wp-content/uploads/2025/06/image-20-802x1024.png 802w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-20-235x300.png 235w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-20-768x980.png 768w, https://www.lemonary.cn/wp-content/uploads/2025/06/image-20.png 1096w" sizes="auto, (max-width: 802px) 100vw, 802px" /></figure>



<h4 class="wp-block-heading">3.4.1 客户端初始化（首次使用）</h4>



<p class="wp-block-paragraph"><strong>a.下载客户端</strong></p>



<pre class="wp-block-code"><code>&#91;root@shine ~]# curl https://get.acme.sh | sh -s email=leonshinel@163.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1032    0  1032    0     0    677      0 --:--:--  0:00:01 --:--:--   676
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  221k  100  221k    0     0   733k      0 --:--:-- --:--:-- --:--:--  733k
&#91;Tue Jun  3 10:39:19 CST 2025] Installing from online archive.
&#91;Tue Jun  3 10:39:19 CST 2025] Downloading https://github.com/acmesh-official/acme.sh/archive/master.tar.gz
&#91;Tue Jun  3 10:39:21 CST 2025] Extracting master.tar.gz
&#91;Tue Jun  3 10:39:21 CST 2025] It is recommended to install socat first.
&#91;Tue Jun  3 10:39:21 CST 2025] We use socat for the standalone server, which is used for standalone mode.
&#91;Tue Jun  3 10:39:21 CST 2025] If you don't want to use standalone mode, you may ignore this warning.
&#91;Tue Jun  3 10:39:21 CST 2025] Installing to /root/.acme.sh
&#91;Tue Jun  3 10:39:21 CST 2025] Installed to /root/.acme.sh/acme.sh
&#91;Tue Jun  3 10:39:21 CST 2025] Installing alias to '/root/.bashrc'
&#91;Tue Jun  3 10:39:21 CST 2025] Close and reopen your terminal to start using acme.sh
&#91;Tue Jun  3 10:39:21 CST 2025] Installing alias to '/root/.cshrc'
&#91;Tue Jun  3 10:39:21 CST 2025] Installing alias to '/root/.tcshrc'
&#91;Tue Jun  3 10:39:21 CST 2025] Installing cron job
&#91;Tue Jun  3 10:39:21 CST 2025] bash has been found. Changing the shebang to use bash as preferred.
&#91;Tue Jun  3 10:39:22 CST 2025] OK
&#91;Tue Jun  3 10:39:22 CST 2025] Install success!</code></pre>



<p class="wp-block-paragraph"><strong>b.注册 ACME 账户</strong></p>



<p class="wp-block-paragraph">不知道为啥第一步环境变量没配上，不过没关系，直接进到目录中进行执行即可</p>



<pre class="wp-block-code"><code>&#91;root@shine .acme.sh]# pwd
/root/.acme.sh
&#91;root@shine .acme.sh]# ./acme.sh --register-account --server https://acmepro.freessl.cn/v2/DV --eab-kid aWm2G_OMBrVt9Ssk_79fnR_cwuUNxvZFAoHm-rTXR3g --eab-hmac-key MD8CAQACCQCm9eI054tO9wIDAQABAggquQyS1v0oAQIFAN6O_gECBQDADDz3AgUA2apAAQIFAKls4ocCBDvEWoM
&#91;Tue Jun  3 10:41:37 CST 2025] Account key creation OK.
&#91;Tue Jun  3 10:41:38 CST 2025] Registering account: https://acmepro.freessl.cn/v2/DV
&#91;Tue Jun  3 10:41:38 CST 2025] Registered
&#91;Tue Jun  3 10:41:38 CST 2025] ACCOUNT_THUMBPRINT='yKX_KD_1TBhifHZdiFhvFb4Ljjl3Lw7VYlNn2xB7-EA'</code></pre>



<h4 class="wp-block-heading">3.4.2 申请部署证书</h4>



<p class="wp-block-paragraph"><strong>a.申请证书</strong></p>



<pre class="wp-block-code"><code>&#91;root@shine .acme.sh]# ./acme.sh --issue --dns dns_tencent -d www.lemonary.cn --server https://acmepro.freessl.cn/v2/DV
&#91;Tue Jun  3 10:43:52 CST 2025] Using CA: https://acmepro.freessl.cn/v2/DV
&#91;Tue Jun  3 10:43:52 CST 2025] Creating domain key
&#91;Tue Jun  3 10:43:52 CST 2025] The domain key is here: /root/.acme.sh/www.lemonary.cn_ecc/www.lemonary.cn.key
&#91;Tue Jun  3 10:43:52 CST 2025] Single domain='www.lemonary.cn'
&#91;Tue Jun  3 10:44:01 CST 2025] Getting webroot for domain='www.lemonary.cn'
&#91;Tue Jun  3 10:44:02 CST 2025] www.lemonary.cn is already verified, skipping dns-01.
&#91;Tue Jun  3 10:44:02 CST 2025] Verification finished, beginning signing.
&#91;Tue Jun  3 10:44:02 CST 2025] Let's finalize the order.
&#91;Tue Jun  3 10:44:02 CST 2025] Le_OrderFinalize='https://acmepro.freessl.cn/v2/finalize/Np1GjvLl'
&#91;Tue Jun  3 10:44:08 CST 2025] Order status is 'processing', let's sleep and retry.
&#91;Tue Jun  3 10:44:11 CST 2025] Polling order status: https://acmepro.freessl.cn/v2/order/Np1GjvLl
&#91;Tue Jun  3 10:44:13 CST 2025] Downloading cert.
&#91;Tue Jun  3 10:44:13 CST 2025] Le_LinkCert='https://acmepro.freessl.cn/v2/cert/75847FE7968914EAC292FF5E8E50CDCCF9D62904'
&#91;Tue Jun  3 10:44:14 CST 2025] Cert success.</code></pre>



<p class="wp-block-paragraph"><strong>b.部署证书</strong></p>



<pre class="wp-block-code"><code>&#91;root@shine .acme.sh]# ./acme.sh --install-cert -d www.lemonary.cn --fullchain-file /usr/local/nginx/ssl/full_chain.pem --key-file /usr/local/nginx/ssl/private.key --reloadcmd "nginx -s reload" 
&#91;Tue Jun  3 10:44:38 CST 2025] The domain 'www.lemonary.cn' seems to already have an ECC cert, let's use it.
&#91;Tue Jun  3 10:44:38 CST 2025] Installing key to: /usr/local/nginx/ssl/private.key
&#91;Tue Jun  3 10:44:38 CST 2025] Installing full chain to: /usr/local/nginx/ssl/full_chain.pem
&#91;Tue Jun  3 10:44:38 CST 2025] Running reload cmd: nginx -s reload
&#91;Tue Jun  3 10:44:38 CST 2025] Reload successful</code></pre>



<p class="wp-block-paragraph"><strong>c.确认开启自动续期</strong></p>



<pre class="wp-block-code"><code>&#91;root@shine .acme.sh]# crontab -l | grep acme
21 15 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" &gt; /dev/null</code></pre>



<p class="wp-block-paragraph">至此，证书的自动化管理已经配置完成。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/%e7%bd%91%e7%ab%99ssl%e8%af%81%e4%b9%a6%e8%bf%87%e6%9c%9f%e6%9b%bf%e6%8d%a2%e6%89%8b%e5%86%8c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>站点健康之HTTP与HTTPS</title>
		<link>https://www.lemonary.cn/%e7%ab%99%e7%82%b9%e5%81%a5%e5%ba%b7%e4%b9%8bhttp%e4%b8%8ehttps/</link>
					<comments>https://www.lemonary.cn/%e7%ab%99%e7%82%b9%e5%81%a5%e5%ba%b7%e4%b9%8bhttp%e4%b8%8ehttps/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Mon, 02 Dec 2024 09:31:59 +0000</pubDate>
				<category><![CDATA[建站记录]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[Nginx]]></category>
		<category><![CDATA[SSL]]></category>
		<category><![CDATA[WordPress]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=711</guid>

					<description><![CDATA[一、概述 不需要了解太详细，我们只需要知道HTTPS比HTTP更安全。简单来说 HTTPS 是 HTTP 的安 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="一、概述">一、概述</h2>



<p class="wp-block-paragraph">不需要了解太详细，我们只需要知道HTTPS比HTTP更安全。简单来说 HTTPS 是 HTTP 的安全版，是使用 TLS/SSL 加密的 HTTP 协议。</p>



<h2 class="wp-block-heading" id="二、把HTTP换成HTTPS">二、把HTTP换成HTTPS</h2>



<h3 class="wp-block-heading" id="2.1-申请证书">2.1 申请证书</h3>



<p class="wp-block-paragraph">免费的，花钱的都可以，能够把证书申请下来就可以。各种云厂商都提供SSL证书服务，例如：<a href="https://www.aliyun.com/">阿里云</a>、<a href="https://cloud.tencent.com/">腾讯云</a>、<a href="https://www.huaweicloud.com/">华为云</a>……也可以用一些免费的，例如：<a href="https://letsencrypt.osfipin.com/">来此加密</a>、<a href="https://freessl.cn/">FREESSL</a>、<a href="https://www.cloudflare-cn.com/">Cloudflare</a>等等。</p>



<p class="wp-block-paragraph">申请证书的过程就不在此介绍了，在申请证书的网站一步一步照着做就可以。</p>



<p class="wp-block-paragraph">证书申请成功后，将证书文件下载，上传到服务器nginx目录。一般只需要上传证书中的证书链文件（fullchain.crt）和私钥文件（private.pem）。【证书文件名大多类似，名字或格式略有差别】</p>



<p class="wp-block-paragraph">我在nginx目录下创建了ssl文件夹，用于存放证书文件：</p>



<pre class="wp-block-code"><code>&#91;root@dameng ssl]# pwd
/usr/local/nginx/ssl
&#91;root@dameng ssl]# ll
total 20
-rw-r--r-- 1 root root 2836 Dec  2 13:29 fullchain.crt
-rw-r--r-- 1 root root 6372 Dec  2 16:47 full_chain.pem
-rw-r--r-- 1 root root 1732 Dec  2 16:47 private.key
-rw-r--r-- 1 root root  241 Dec  2 11:31 private.pem</code></pre>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">注意<br>我存放了两套证书，所以有四个文件，正常情况下有一套就可以。</p>
</blockquote>



<h3 class="wp-block-heading" id="2.2-修改nginx配置">2.2 修改nginx配置</h3>



<p class="wp-block-paragraph">编辑配置文件nginx.conf，只需要修改server部分就行</p>



<pre class="wp-block-code"><code>server {
        listen 80;
        server_name 你的域名;
        #将HTTP重定向到HTTPS
        return 301 https://$server_name$request_uri;
}
server
    {
        listen 443 ssl;
        ssl_stapling on;
        ssl_stapling_verify on;
        #请填写证书文件的相对路径或绝对路径
        ssl_certificate "/usr/local/nginx/ssl/full_chain.pem";
        #请填写私钥文件的相对路径或绝对路径
        ssl_certificate_key "/usr/local/nginx/ssl/private.key";
        
        #listen 80 default_server reuseport;
        #listen &#91;::]:80 default_server ipv6only=on;
        server_name 你的域名;
        ……
        ……
        ……</code></pre>



<p class="wp-block-paragraph">保存并重新加载nginx</p>



<pre class="wp-block-code"><code>&#91;root@dameng conf]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
&#91;root@dameng conf]# nginx -s reload</code></pre>



<h2 class="wp-block-heading" id="三、其他问题">三、其他问题</h2>



<p class="wp-block-paragraph">由于我在申请SSL证书的同一天将域名解析到我的IP（也就是网站IP与域名绑定），碰到了一些意料之外的问题：</p>



<ol class="wp-block-list">
<li>网站上所有的图片都加载不出来。</li>



<li>还有一个神奇的现象，就是页面加载后会把我底部音乐播放器的音乐封面铺满整个网页。</li>
</ol>



<p class="wp-block-paragraph">后续我也找到了解决的方法：准备工作是要下载一个插件<strong>Unlimited Elements for Elementor</strong>。</p>



<ol class="wp-block-list">
<li>图片加载不出来是因为图片都在WordPress媒体库并且图片的链接还是以前的IP链接，例如：https://xxx.xxx.xxx.xxx/wp-content/uploads/2024/11/头像-e1731570721610.jpg，需要将媒体库文件链接中所有的IP替换掉。当然不用一个一个的改，从WordPress的设置-常规里把<strong>WordPress地址（URL）</strong>和<strong>站点地址（URL）</strong>修改成域名。修改完成后，再次登录WordPress管理界面时，上述插件<strong>Unlimited Elements for Elementor</strong>会提示将网站从IP地址<strong>迁移</strong>到新的域名，点击<strong>迁移</strong>即可解决问题。</li>



<li>另外，音乐播放器封面的问题，我怀疑是我在申请SSL证书时没有填写顶级域名（lemonary.cn）而是只填了二级域名（www.lemonary.cn）导致的，我没有证实这一问题。但是在我将只填了二级域名的SSL证书替换掉后，这个现象也就没再出现过。</li>
</ol>



<p class="wp-block-paragraph">所以大家在替换域名和申请SSL证书时要注意以下两点：</p>



<ol class="wp-block-list">
<li>WordPress的媒体库中的文件链接需要修改，可以用插件统一修改。</li>



<li>SSL证书申请时一定要写好两个域名：顶级域名和二级域名（带www的和不带www的）。</li>
</ol>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/%e7%ab%99%e7%82%b9%e5%81%a5%e5%ba%b7%e4%b9%8bhttp%e4%b8%8ehttps/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
