时间:2022-07-24 12:36:01 | 来源:网站运营
时间:2022-07-24 12:36:01 来源:网站运营
wget https://dl.eff.org/certbot-autochmod a+x certbot-auto
使用certbot申请安装证书:./certbot-auto certonly --webroot --apache -w /data/wwwroot/www.chanzhi cms.com -d www.chanzhicms.com --no-self-upgrade
-w后面是网站的根目录路径,-d后面是申请证书的域名,多个域名的话,在后面继续添加设置多个-d即可。LoadModule ssl_module modules/mod_ssl.soInclude conf/extra/httpd-ssl.conf然后修改/usr/local/apache/conf/extra/httpd-ssl.conf 文件,将里面内容清空,放入下面内容:Listen 443AddType application/x-x509-ca-cert .crtAddType application/x-pkcs7-crl .crlSSLCipherSuite EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5SSLProxyCipherSuite EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5SSLHonorCipherOrder onSSLProtocol all -SSLv2 -SSLv3SSLProxyProtocol all -SSLv2 -SSLv3SSLPassPhraseDialog builtinSSLSessionCache "shmcb:/usr/local/apache/logs/ssl_scache(512000)"SSLSessionCacheTimeout 300Mutex sysvsem defaultSSLStrictSNIVHostCheck on
最后修改网站的单独配置文件,/usr/local/apache/conf/vhost/www.chanzhicm.com.conf ,原本只有80端口配置,这里需要我们加上443端口的配置: ServerAdmin admin@linuxeye.com DocumentRoot "/data/wwwroot/www.chanzhicms.com" ServerName www.chanzhicms.com ServerAlias chanzhicms.com ErrorLog "/data/wwwlogs/www.chanzhicms.com_error_apache.log" CustomLog "/data/wwwlogs/www.chanzhicms.com_apache.log" combined SetOutputFilter DEFLATE Options FollowSymLinks ExecCGI Require all granted AllowOverride All Order allow,deny Allow from all DirectoryIndex index.html index.phpListen 443 DocumentRoot "/data/wwwroot/www.chanzhicms.com" ServerName www.chanzhicms.com:443 ServerAlias www.chanzhicms.com ErrorLog "/data/wwwlogs/www.chanzhicms.com_error_apache.log" ServerAdmin admin@linuxeye.com SSLEngine on SSLCertificateFile /etc/letsencrypt/live/www.chanzhicms.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/www.chanzhicms.com/privkey.pem SetOutputFilter DEFLATE Options FollowSymLinks AllowOverride All Order allow,deny Allow from all DirectoryIndex index.html index.php Require all granted
上面配置中的网站名称、网站路径、证书路径等信息,大家根据自己的具体情况填写。certbot-auto renew --no-self-upgrade
成功后,检查更新到期日期./certbot-auto certificates
证书到期之前会有邮件提醒,这里介绍修改新订阅邮箱的方法:./certbot-auto update_account --email 963370407@qq.com --no-self-upgrade
yum install vixie-cron crontabs //安装Crontabchkconfig crond on //设为开机自启动service crond start //启动
/var/spool/cron 这里是所有的自动执行任务的 cron 文件存放位置(root文件)30 20 1 * * /root/certbot-auto renew --no-self-upgrade
即每月1号晚上8点半更新证书。service crond restart
查看crontab定时执行任务列表crontab -l
vim ~/.pip/pip.conf[global]index-url=https://pypi.tuna.tsinghua.edu.cn/simple/[install]trusted-host=pypi.tuna.tsinghua.edu.cn
改保存后,再试试 ./certbot-auto renew --no-self-upgrade 就正常了。Attempting to renew cert (www.chanzhicms.com) from /etc/letsencrypt/renewal/www.chanzhicms.com.conf produced an unexpected error: The manual plugin is not working; there may be problems with your existing configuration.The error was: PluginError('An authentication script must be provided with --manual-auth-hook when using the manual plugin non-interactively.',). Skipping.All renewal attempts failed. The following certs could not be renewed: /etc/letsencrypt/live/www.chanzhicms.com/fullchain.pem (failure)
解决方法:vim /etc/letsencrypt/renewal/www.chanzhicms.com.sh#!/bin/bashecho $CERTBOT_VALIDATION > /path/to/wwwroot/.well-known/acme-challenge/$CERTBOT_TOKEN
其中,/path/to/wwwroot/ 为您域名验证的网站根目录chmod +x /etc/letsencrypt/renewal/www.chanzhicms.com.sh
带参数执行命令certbot-auto renew --no-self-upgrade --manual-auth-hook /etc/letsencrypt/renewal/www.chanzhicms.com.sh
成功后,检查更新到期日期./certbot-auto certificates --no-self-upgrade
关键词:证书,升级,申请