安装mod_ssl模块,让apache支持https
yum install mod_ssl
生成证书和密钥
生成密钥
openssl genrsa 2048 > server.key
说明:这是用128位rsa算法生成密钥,得到server.key文件
生成证书请求文件
openssl req -new -key server.key > server.csr
说明:这是用步骤1的密钥生成证书请求文件server.csr, 这一步提很多问题,一一输入
生成证书请求文件
openssl req -new -key server.key > server.csr
说明:这是用步骤1的密钥生成证书请求文件server.csr, 这一步提很多问题,一一输入
配置apache
<VirtualHost sobird.me:443>
ServerName sobird.me
SSLProtocol all -SSLv2
SSLEngine on
SSLCipherSuite DEFAULT:!EXP:!SSLv2:!DES:!IDEA:!SEED:+3DES
SSLCertificateFile /path/to/conf/ssl.crt/server.crt
SSLCertificateKeyFile /path/to/conf/ssl.key/server.key
SSLCACertificateFile /path/to/conf/ssl.crt/ca_bundle.crt
DocumentRoot /web/blog
<Directory /web/blog>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*)$ index.php/$1 [L]
</IfModule>
</Directory>
ErrorLog logs/sobird.me-error_log
CustomLog logs/sobird.me-access.log combined
</VirtualHost>
重启web服务后,博客即支持https访问了,但此时在浏览器中访问,你的证书是可信的,地址栏里的小锁是灰色,那如何让小锁变成绿色呢?
申请沃通两年免费SSL证书
沃通(WoSign): https://buy.wosign.com/free/
根据网站提示,得到有效期两年的CSR证书压缩包,里面包含(apache,nginx,iis等证书)。
证书配置
下载沃通的证书压缩包,选在apache版本,解压后得到类似下面两个文件:
1_root_bundle.crt
2_sobird.me.crt
修改apache的配置如下:
SSLCertificateFile /path/to/conf/ssl.crt/2_sobird.me.crt
SSLCertificateKeyFile /path/to/conf/ssl.key/server.key
SSLCACertificateFile /path/to/conf/ssl.crt/1_root_bundle.crt
防火墙配置
加入或修改为以下规则
-A INPUT -p tcp --dport 443 -j ACCEPT
最后修改wordpress后台配置
进入设置->常规
将 http://sobird.me 更新为https://sobird.me
将原来的http改为https,本文并没有强制301跳转到https,所以目前博客文章支持 http和https可同时访问,只是访问进入到我的博客后才会定向到https的页面。
这篇文章目前没有评论。