git clone https://github.com/letsencrypt/letsencrypt cd letsencrypt chmod +x letsencrypt-auto
./letsencrypt-auto certonly -a webroot --webroot-path=/home/www/demo.com --email email@yourname.com -d demo.com-d www.demo.com
將目錄、郵箱和域名換成你本身的
就說明安裝證書成功了!
而且能看到證書的目錄:/etc/letsencrypt/live/
demo.com
css
該目錄下有四個文件nginx
cert.pem - Apache 服務器端證書 chain.pem - Apache 根證書和中繼證書 fullchain.pem - Nginx 所須要 ssl_certificate 文件 privkey.pem - 安全證書 KEY 文件
打開 nginx 配置文件,個人是:/usr/local/nginx/conf/vhost/default.conf
。
修改記錄:
git
server {
github
listen 80;
web
server_name localhost;
return 301 https://$server_name$request_uri;安全
}
bash
ssl.conf 中:
ssl_certificate /etc/letsencrypt/live/demo.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/demo.com/privkey.pem;
保存以後,重啓nginx服務器