1. Get let ' s Encrypt
clone https://github.com/letsencrypt/letsencryptcd letsencryptchmod +x letsencrypt-auto
2. Execute Installation Certificate
-a webroot --webroot-path=/home/www/demo.com --email [email protected] -d
-d www.
demo.com
Replace directories, mailboxes, and domain names with your own
It means the installation certificate is successful!
and can see the directory of the certificate:
/etc/letsencrypt/live/
demo.com
There are four files in this directory
cert.pem - Apache 服务器端证书 chain.pem - Apache 根证书和中继证书 fullchain.pem - Nginx 所需要 ssl_certificate 文件 privkey.pem - 安全证书 KEY 文件
3. Modify Nginx configuration file
Open nginx config file, mine is: /usr/local/nginx/conf/vhost/default.conf
.
To modify a record:
server {
listen 80;
server_name localhost;
Return 301 https://$server _name$request_uri;
}
ssl.conf 中:
ssl_certificate /etc/letsencrypt/live/demo.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/demo.com/privkey.pem;
After saving, restart Nginx
HTTPS deployment practices (let ' s Encrypt)