skysilk主机上的博客加ssl以实现https访问

因为谷歌倡导https,现在你做个网站如果还是http访问,总感觉有点不踏实,而我自己也觉得丢人,因为用caddy实现证书是非常简单的事,所以我尝试着给skysilk主机上的博客加个证书以实现逼格访问。

因为自己不是学这个也不是从事这行(简称,外行),我查询了大量资料,以下是我认为比较有用的网址:

首先是skysilk自己的support页面:

https://help.skysilk.com/support/solutions/articles/9000139836-how-to-install-let-s-encrypt-on-ubuntu-linux-vps-to-create-ssl-certificates

还有就是简书的两个页面,感谢原作者:

https://www.jianshu.com/p/74d5a14b335d

https://www.jianshu.com/p/965ec3a8bff2

然后我就开始了

第一个坑,就是原skysilk里边提到的这个命令:

apt-get update & sudo apt-get upgrade

在它自己的ubuntu18.04系统上,跑完这个命令,提示

update Reading package lists… Done

网上也没啥好的想法,后来我自己灵机一动,把这两个命令拆开了分别先后执行,ok

然后到了:

./letsencrypt-auto certonly --standalone -d example.com -d www.example.com

这里的时候,卡住了,并没有live这个目录,我后来看了 StevenQin 的帖子,想到了需要把apache2停掉,于是跑service apache2 stop 之后,再执行一次上面那行命令,live目录有了,进去里边有我域名目录,里边有证书,key

当然中间会提示你输入邮箱,同意他的term,还有一个询问就是要不要记录我的邮箱,我选择no

本以为这就好了,但敲https://iwilz.com,不行,只好继续翻看stephen__liu的文章,抄了他的一些文字:

<VirtualHost *:443>
DocumentRoot "博客内容目录地址"
ServerName iwilz.com
ServerAlias iwilz.com
SSLEngine on
SSLProtocol TLSv1 TLSv1.1 TLSv1.2
SSLCertificateFile /etc/letsencrypt/live/iwilz.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/iwilz.com/privkey.pem
</VirtualHost>

然后service apache2 restart

出错了,提示

Job for apache2.service failed because the control process exited with error code.
See “systemctl status apache2.service” and “journalctl -xe” for details.

我输入了systemctl status apache2.service

得到了提示:

Invalid command ‘SSLEngine’, perhaps misspelled or defined by a module not i

我把前边那句输入谷歌寻求帮助,找到这个帖子:

http://www.emreakkas.com/linux-tips/invalid-command-sslengine-enabling-ssl-on-ubuntu-server

按照他的说法,需要enable ssl

于是输入a2enmod ssl

后来才发现,其实liu已经给出了答案,当时给搞懵了,不知道答案就在眼前。

然后就是http跳转https功能,把下面三行加到 VirtualHost *:80 这个段落里边

RewriteEngine on
RewriteCond   %{HTTPS} !=on
RewriteRule   ^(.*)  https://%{SERVER_NAME}$1 [L,R]

这个文件就在/etc/apache2/sites-enabled里边

完了。

点赞

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注