免费https证书制作 certbot

0.环境

系统:centos6.5

服务器:Apache/2.4.17

1.安装

wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
./certbot-auto

2.配置

修改./apache/config/httpd.conf

为正确的ServerName

ServerName www.xxx.com:80

修改或添加下列配置./apache/config/extra/httpd-vhost.conf

需要先注释掉SSL相关的配置防止出错

<VirtualHost *:443>
    DocumentRoot "/DocumentRoot"
    ServerName xxx.com
    ServerAlias www.xxxx.com
#    SSLEngine on
#    SSLCertificateFile /etc/letsencrypt/live/www.xxx.com/fullchain.pem
#    SSLCertificateKeyFile /etc/letsencrypt/live/www.xxx.com/privkey.pem
    <Directory "/DocumentRoot">
        RewriteEngine on

        RewriteBase /
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} !=/favicon.ico
        RewriteRule ^ index.php [L]
        Options -Indexes +FollowSymLinks

        AllowOverride None
        Require all granted
    </Directory>

</VirtualHost>

重启apache

service httpd restart 

或者./apache/bin/apachectl restart

3.获取证书

./certbot-auto certonly --email xxx@xxx.com --agree-tos --webroot -w /www -d www.xxx.com
多域名多目录生成一个证书:(即一次生成多个域名的一个证书)
./certbot-auto certonly --email xxx@xxx.com --agree-tos --webroot -w /home -d xxx.com -d xx.com -w /www -d xxx.org -d xx.org

正常情况下证书会存在 /etc/letsencrypt/live/www.xxx.com目录中

然后放开./apache/config/extra/httpd-vhost.conf中的SSL相关配置

重启apache

4.以上方法无法正常处理多域名多证书时

请注意看懂提示再处理,没看懂提示乱操作的后果不堪设想

首先创建一个单域名证书

./certbot-auto certonly --email xx@xx.com --agree-tos --webroot -w /xxx -d x.xxx.com

在一个一个域名的加进到生成的证书中。

其中有一项选择,我选择的,就是字面意思。Place files in webroot directory (webroot)

该命令会提示更新详情,注意看清楚。

还会提示输入新加入域名的路径。

./certbot-auto certonly --cert-name x.xxx.com -d xx.xxx.com -d xxxx.com

 

温馨提示:

每次更新证书都需要重启apache。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值