Certbot 使用 XAMPP 在 Ubuntu 16.04 上自动生成证书

Posted

技术标签:

【中文标题】Certbot 使用 XAMPP 在 Ubuntu 16.04 上自动生成证书【英文标题】:Certbot generate cert automatically on Ubuntu 16.04 with XAMPP 【发布时间】:2020-09-13 09:43:24 【问题描述】:

我遇到了我无法通过'--apachectl'执行相同逻辑的情况, 和certbot说它是折旧的,然后我发现版本不是16.04的最新版本, 而且我无法将操作系统升级到 18.04,所以我必须尝试另一种方法来自动生成证书。

【问题讨论】:

【参考方案1】:

我解决了这个案子,如果有帮助,想在这里分享给别人。

我的案例中的 XAMPP 虚拟主机

Webroot 路径

/opt/lampp/htdocs/abcd.com/

虚拟主机配置

/opt/lampp/etc/extra/httpd-vhosts.conf

<VirtualHost *:80>
DocumentRoot  "/opt/lampp/htdocs/abcd.com"
ServerName abcd.com
<Directory "/opt/lampp/htdocs/abcd.com">
        Options Includes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
</Directory>
ErrorLog "/opt/lampp/htdocs/abcd.com/domain_error_log"
ErrorDocument 404 '404'
</VirtualHost>

.众所周知

/opt/lampp/htdocs/abcd.com/.well-known/acme-challenge

1。我们将通过创建执行文件(.sh)来使用 --manual-auth-hook --manual-cleanup-hook 时的重要步骤

1.1 创建authenticator.sh

sudo nano /opt/lampp/htdocs/abcd.com.authenticator.sh
#----- copy and paste -----
#!/bin/bash
echo $CERTBOT_VALIDATION > /opt/lampp/htdocs/Project/vtl-solutions.com/.well-known/acme-challenge/$CERTBOT_TOKEN
#----- copy and paste -----

sudo chmod -R 777  /opt/lampp/htdocs/abcd.com.authenticator.sh

1.2 创建cleanup.sh

sudo nano /opt/lampp/htdocs/abcd.com.cleanup.sh
#----- copy and paste -----
#!/bin/bash
rm -f /opt/lampp/htdocs/abcd.com/.well-known/acme-challenge/$CERTBOT_TOKEN
#----- copy and paste -----

sudo chmod -R 777  /opt/lampp/htdocs/abcd.com.cleanup.sh

2。我们现在可以运行命令来做

sudo certbot certonly --manual \
 --preferred-challenges=http \
 --manual-auth-hook /opt/lampp/htdocs/abcd.com.authenticator.sh \
 --manual-cleanup-hook /opt/lampp/htdocs/abcd.com.cleanup.sh \
 -d abcd.com

这里有一个细节和执行日志供参考:

https://github.com/oliguo/Server-Certbot-XAMPP-Ubuntu

【讨论】:

以上是关于Certbot 使用 XAMPP 在 Ubuntu 16.04 上自动生成证书的主要内容,如果未能解决你的问题,请参考以下文章

在 xampp Apache Ubuntu 上设置 Certbot

ubuntu使用certbot获取ssl证书

ubuntu nginx 安装 certbot(letsencrypt)

在 laravel 应用程序、Apache、Ubuntu 20.04 上安装 Certbot 软件并配置 HTTPS 后 HTTPS:// 链接断开 |数字海洋

markdown 添加ppa dan install certbot di ubuntu linux

在Ubuntu使用 Let's Encrypt 证书部署 HTTPS的方法