免费https证书申请

 

建议大家看原作者的,很清晰

 

当前工作目录为 /root

获取certbot

/sbin/service nginx start
chmod a+x certbot-auto


停止nginx

service nginx stop

 


生成证书(如果后期生成报错,先删除原有certbot-auto,按第一步重新下载certbot即可)

#使用-d追加多个域名,使用时请将邮箱换成自己的邮箱

./certbot-auto certonly --standalone --email cdw.me@qq.com --agree-tos -d cdw.me -d www.cdw.me -d wiki.cdw.me

 生成过程可能有点慢,要耐心等待下。

查看生成的证书

ls /etc/letsencrypt/live/

如果报错执行下面 certbot或者 ./certbot-auto  certonly --webroot -w 网站根目录 -d 网址 -m 邮箱 --agree-tos

在nginx配置证书

#证书位置
ssl_certificate /etc/letsencrypt/live/cdw.me/fullchain.pem;
# 私钥位置
ssl_certificate_key /etc/letsencrypt/live/cdw.me/privkey.pem;
启动nginx

service nginx start

 

编写更新脚本renew-cert.sh

#!/bin/bash
# 停止nginx
/sbin/service nginx stop
 
# 续签
# --force-renew 强制更新
/root/certbot-auto renew --force-renew
 
# 启动nginx
/sbin/service nginx start


chmod a+x renew-cert.sh

 

自动更新https证书

//crontab定时任务自动更新证书
0 4 1 */2 * /root/renew-cert.sh >/root/crontab.log 2>&1
Let’s Encrypt 生成的免费证书为3个月时间,但是我们可以无限次续签证书

注意:定时任务可能会失败,请在/root/crontab.log中查看错误原因。
常见错误:
1.pip prints the following errors
解决方案:

# 备份pip配置
cp ~/.pip/pip.conf ~/.pip/pip.aliyun.conf
# 修改pip配置将镜像地址改为清华源
vi ~/.pip/pip.conf
  
  [global]
  index-url=https://pypi.tuna.tsinghua.edu.cn/simple
 
  [install]
  trusted-host=pypi.tuna.tsinghua.edu.cn
2.service:command not found
解决方案:

  # 使用完整的service完整路径,修改renew-cert.sh文件,在service命令前加上/sbin/
  /sbin/service nginx stop
  /sbin/service nginx start
版权声明:本文内容由互联网用户自发贡献,版权归作者所有,本社区不拥有所有权,也不承担相关法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件至:yqgroup@service.aliyun.com 进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容。

 

<VirtualHost *:443>
    DocumentRoot "/home/www/shucai/flow_platform_material/shucai"
    ServerName c.wanwanws.com
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/c.wanwanws.com/fullchain.pem   //之前生成的证书
    SSLCertificateKeyFile /etc/letsencrypt/live/c.wanwanws.com/privkey.pem    //之前生成的密钥
    <Directory "/home/www/shucai/flow_platform_material/shucai">
    Options FollowSymLinks ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
     Require all granted
    </Directory>
 </VirtualHost>
--------------------- 
作者:weixin_41647577 
来源:CSDN 
原文:https://blog.csdn.net/weixin_41647577/article/details/84834392 
版权声明:本文为博主原创文章,转载请附上博文链接!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值