目的
申请域名证书 (DV SSL)
1. 使用acme 自动签发
1.1 下载acme脚本(可以不用这一步)
git clone https://github.com/acmesh-official/acme.sh
1.2 安装zcem
curl https://get.acme.sh | sh
1.3 运行脚本自动签发
~/.acme.sh/acme.sh --issue -d 域名 --webroot web目录
签发成功如下

注:使用acme命令之前需要先注册帐务使用命令即可,填入自己的邮箱
https://github.com/acmesh-official/acme.sh/wiki/ZeroSSL.com-CA

1.4 签发成功后修改域名证书的存放位置
默认签发成功后的位置如:

使用以下命令修改存放位置以供使用
~/.acme.sh/acme.sh --install-cert -d 域名 \
--key-file 密钥存放目录 \
--fullchain-file 证书存放路径
2. 配置
2.1 Apache 配置
2.2.1. 编辑网站配置文件,例如 /etc/apache2/sites-enabled/xxx.conf ,添加443端口和相关配置:
<VirtualHost *:443>
ServerName tlanyan.pp.ua
# 日志等其他配置
# ssl配置
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/tlanyan.pp.ua/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/tlanyan.pp.ua/privkey.pem
</VirtualHost>
注:如果apache第一次使用ssl,需要开启 ssl mod,使用命令
a2enmod ssl
否则会报错:

2.2.2 重启apache服务
systemctl restart apache2.service
参考
- 「apache2无效的命令'SSLEngine'」https://qastack.cn/unix/31378/apache2-invalid-command-sslengine
网友评论