ssl-guides 2026-12-02 ⏱ 1 min read

用 acme.sh 获取免费 SSL 证书

用 acme.sh 获取免费 SSL 证书
快速回答:安装 acme.sh,把 Let's Encrypt 设为默认 CA,用 acme.sh --issue 签发证书,然后配合重载命令使用 acme.sh --install-cert,让续期自动部署。

acme.sh:安装

curl https://get.acme.sh | sh -s email=admin@example.com
source ~/.bashrc

安装程序会添加一个每日 cron 任务。如果你的环境在意这一点,请在把脚本通过管道交给 shell 之前先检查它。然后设置 CA,因为较新版本的 acme.sh 默认使用 ZeroSSL:

acme.sh --set-default-ca --server letsencrypt

签发证书

方法命令适用场景
Webrootacme.sh --issue -d example.com -d www.example.com -w /var/www/html站点已在 80 端口运行
Standaloneacme.sh --issue -d example.com --standalone没有任何程序占用 80 端口
DNS APIacme.sh --issue -d example.com -d '*.example.com' --dns dns_cf通配符,或 80 端口未开放

对于 Cloudflare DNS,先用 export CF_Token="..." 导出 API 令牌,以及插件文档中说明的账户或区域 ID。acme.sh 会为续期保存它们。

为你的服务器安装证书

不要让服务器指向 acme.sh 的内部文件夹。把文件复制到稳定的路径,然后重载:

acme.sh --install-cert -d example.com \
  --key-file       /etc/ssl/example.com/privkey.pem \
  --fullchain-file /etc/ssl/example.com/fullchain.pem \
  --reloadcmd      "systemctl reload nginx"

在 Nginx 或 Apache 配置中使用相同的路径。acme.sh 会记住这些设置,并在每次续期后运行重载命令。

acme.sh:续期

cron 任务每天调用 acme.sh --cron,并续期到期的证书。用以下命令测试和检查:

acme.sh --list
acme.sh --renew -d example.com --force

请谨慎使用 --force,因为重复签发可能触及速率限制。用SSL 检查工具核对结果。

acme.sh 还是 Certbot?

acme.shCertbot
依赖纯 shell 脚本Python 或 snap
DNS 提供商插件许多内置独立插件
自动编辑 Web 服务器配置否是,需配合插件

另一个选择请参见 Certbot 指南。如果你只需要一个快速的一次性证书,TryFreeSSL.com 可以在浏览器中签发。

故障排查

  • 加上 --debug 运行,查看验证详情。
  • 用 DNS Lookup 检查 DNS 是否指向该服务器。
  • 确保重定向没有破坏 HTTP 验证路径。
  • 触发速率限制?请等待,并在测试时使用带 --staging 的 staging 服务器。

相关阅读:用 Certbot 获取证书、自动化续期和HTTP-01 验证。

常见问题

应该用 root 运行 acme.sh 吗?

请以拥有证书文件的用户运行,并只授予该用户重载服务所需的权限。在简单的服务器上使用 root 很常见。

证书存放在哪里?

存放在 acme.sh 自己的主目录中。务必使用 --install-cert 部署副本。

它支持通配符吗?

支持,通过 DNS 验证。

如何迁移到另一台服务器?

复制 acme.sh 的账户和域名文件夹,或在新主机上签发新证书。

运行 acme.sh 需要 root 吗?

只有安装到系统路径和重载 Web 服务器时才需要。客户端以普通用户运行,cron 任务也可以在该用户下运行。

证书存放在哪里?

默认在 ~/.acme.sh// 下。安装命令会把它们复制到你的 Web 服务器读取的路径。

它支持通配符吗?

支持,通过其某个 DNS API 插件完成 DNS-01 验证。HTTP-01 无法签发通配符证书。

🔒 Test Your Website SSL Certificate Now
Run Free SSL Check →

✅ Post-Installation Verification & SEO Checklist

After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:

  • Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
  • Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
  • Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
  • Confirm both root and www versions resolve cleanly to one canonical HTTPS URL.
  • Verify your HTTPS property and sitemap.xml inside Google Search Console and Bing Webmaster Tools.
Technically Reviewed by TryFreeSSL Security Team
Last updated: 2026-12-05
About Us →

免费 SSL 证书签发、在线 SSL 检测与 CSR 生成器

无需复杂服务器配置,60 秒快速获取 Let's Encrypt 与 Buypass 信任的 HTTPS 证书。

Related Articles

🤖 TryFreeSSL AI Assistant