免费SSL证书申请、安装图文教程

SSL证书很大程度上增加了数据传输安全,现在很多大型网站都上了SSL证书,如谷歌、百度等。但是对小型网站来说,花巨额的费用还是受不了的,今天VPS评测与排名站就交大家申请、安装免费的SSL证书,让您的网站也高大上一次。

免费SSL证书选择

免费SSL证书目前比较多,不过VPS评测与排名网推荐大家使用Let’s Encrypt。使用免费Let’s Encrypt的SSL证书理由非常简单。

1、可靠

大型互联网公司发起,其是公益组织运营,由 Linux 基金会托管。这就保障了这个免费的SSL证书可靠了。

2、兼容性好

目前免费的SSL证书中,Let’s Encrypt免费SSL证书是最好的,无论是火狐还是谷歌浏览器、还是IE都兼容,这点非常难得。

3、申请安装方便

这点就更值得一提了,目前Let’s Encrypt免费SSL证书推出了certbot-auto方案安装后,VPS及独立服务器上安装Let’s Encrypt免费SSL证书非常快捷方便。

4、免费

这点就不多说了,Let’s Encrypt免费SSL证书估计会一直免费下去,大家使劲用吧。

好了,以上说明了为什么选择并使用Let’s Encrypt免费SSL证书,下面就来写如何在VPS或独立服务器上申请安装Let’s Encrypt免费SSL证书。

免费SSL证书申请、安装

这里就不多说了,以VPS评测与排名网最常用的操作系统CentOS 系统说明。

CentOS 6、7下,root登录命令行,执行:

yum install epel-release

然后在root下依次执行以下语句:

cd /root/
wget https://dl.eff.org/certbot-auto --no-check-certificate
chmod +x ./certbot-auto
./certbot-auto -n

./certbot-auto -n只是用来安装依赖包的,也可以跳过直接到下面的生成证书的步骤。

单域名生成证书:

./certbot-auto certonly --email [email protected] --agree-tos --no-eff-email --webroot -w /home/wwwroot/www.vpsrr.com -d www.vpsrr.com

多域名单目录生成单证书:

./certbot-auto certonly --email [email protected] --agree-tos --no-eff-email --webroot -w /home/wwwroot/www.vpsrr.com -d www.xvpsrr.com -d test.vpsrr.com

多域名多目录生成一个证书:

./certbot-auto certonly --email [email protected] --agree-tos --no-eff-email --webroot -w /home/wwwroot/www.vpsrr.com -d www.vpsrr.com -d bbs.vpsrr.com -w /home/wwwroot/www.vpsrr1.com -d www.vpsrr1.com -d vpsrr1.com

如果提示以下内容,安装免费SSL成功。

IMPORTANT NOTES:
– Congratulations! Your certificate and chain have been saved at
/etc/letsencrypt/live/www.vpsrr.com/fullchain.pem. Your cert will
expire on 2017-9-01. To obtain a new or tweaked version of this
certificate in the future, simply run certbot-auto again. To
non-interactively renew *all* of your certificates, run
“certbot-auto renew”
– If you like Certbot, please consider supporting our work by:

Donating to ISRG / Let’s Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

生成的证书会存在:/etc/letsencrypt/live/www.vpsrr.com/ 目录下。

很明显,Let’s Encrypt免费SSL证书只能用三个月,到期前执行以下命令,即可续期三个月:

certbot-auto renew

结合crontab即可实现自动续期了,可以让以上命令每月执行一次。

完成以上后,再就是修改nginx.conf文件了。这里,VPS评测与排名网给个示范:

server
{
listen      80;
server_name www.vpsrr.com vpsrr.com;
return      301 https://www.vpsrr.com$request_uri;
#index index.html index.htm index.php default.html default.htm default.php;
#root  /home/wwwroot/www.vpsrr.com;
}

server
{
#listen 80;
listen 443 ssl;
#listen [::]:80;
server_name www.vpsrr.com vpsrr.com;
index index.html index.htm index.php default.html default.htm default.php;
root  /home/wwwroot/www.vpsrr.com;
ssl on;
ssl_certificate /etc/letsencrypt/live/www.vpsrr.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.vpsrr.com/privkey.pem;
ssl_ciphers “EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5”;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 24h;

include wordpress.conf;
#error_page   404   /404.html;

………

自己对照修改,就能成功【特别注意vpsrr.com及vpsrr1.com部分,一定要结合自己情况修改】。

修改后重启LNMP,再访问试试,是不是网站已经支持高大上的SSL安全证书了。

VPS评测与排名网特别提示:如果你使用了如七牛加速等,那估计要停用了,要想完全“绿锁”出现,就必须全部SSL出来,不能出现非SSL外链,另外最好不用其它调用的如js等外链,部分浏览器会提示SSL证书不一致。

以上就是安装免费SSL证书的全过程,希望能帮到部分需要的人。当然,本人也是小白一枚,如有错误欢迎指正,谢谢。