免費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。

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