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.ddbaodai.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
正常情况下证书会存在 /etc/letsencrypt/live/www.xxx.com目录中
然后放开./apache/config/extra/httpd-vhost.conf中的SSL相关配置
重启apache