使用certbot在nginx搭建HTTPS
certbot
certbot官⽹
apache配置文档
安装证书自动工具 certbot
yum install -y epel-release
yum -y install yum-utils
yum-config-manager --enable rhui-REGION-rhel-server-extras rhuiREGION-rhel-server-optional
sudo yum install certbot
# sudo certbot certonly
如果执行certbot报错
## pkg_resources.DistributionNotFound: The 'urllib3<1.23,>=1.21.1' distribution was not found and is required by requests
rm /usr/lib/python2.7/site-packages/urllib3* -rf
python2.7 -m pip install urllib3
## ImportError: 'pyOpenSSL' module missing required functionality.
Try upgrading to v0.14 or newer.
pip show pyOpenSSL
yum remove certbot pyOpenSSL
pip uninstall pyOpenSSL
yum install -y python-devel
yum install -y openssl-devel
pip install certbot certbot certificates
配置Nginx
vi /usr/local/nginx/conf/nginx.conf
[In server{}]
location ^~/.well-known/acme-challenge/ {
default_type "text/plain";
root /data/www;
}
service nginx reload
申请证书
Web+FS服务器器 192.168.1.152
certbot certonly --webroot \
-w /data/www \
-d <域名> \
-d <域名> \
-d <域名>
[root@izuf6b281zcjzt94z7ikdlz nginx]# certbot certonly --webroot -w /data/www -d <域名> -d <域名> -d <域名> -d <域名> -d <域名>
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer None
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
You have an existing certificate that contains a portion of the domains you
requested (ref: /etc/letsencrypt/renewal/<域名>)
It contains these names: <域名>,
<域名>, <域名>
You requested these names for the new certificate: <域名>,
<域名>, <域名>,
<域名>, <域名>.
Do you want to expand and replace this existing certificate with the new
certificate?
- - - - - -