免费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 [email protected] --agree-tos --webroot -w /www -d www.xxx.com
多域名多目录生成一个证书:(即一次生成多个域名的一个证书)
./certbot-auto certonly --email [email protected] --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 [email protected] --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。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章