欢迎来到日本小春精选,了解日本先从@日本生活基础课程开始!
欢迎 欢迎     登录 | 注册      消息
当前位置: 首页小组技术交流为lnmp平台下WORDPRESS网站配置后台/登录页面强制HTTPS加密

[Linux]为lnmp平台下WORDPRESS网站配置后台/登录页面强制HTTPS加密

<div style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 13px; line-height: 18px; "><span style="font-family: 'Microsoft Yahei'; ">安装openssl</span></div><div style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 13px; line-height: 18px; "><span style="font-family: 'Microsoft Yahei'; ">debian,ubuntu等发行版下用以下命令: sudo apt-get install openssl</span></div><div style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 13px; line-height: 18px; "><span style="font-family: 'Microsoft Yahei'; ">redhat,centos等发行版下用:yum install openssl</span></div><div style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 13px; line-height: 18px; "><span style="font-family: 'Microsoft Yahei'; "><br /></span></div><div style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 13px; line-height: 18px; "><span style="font-family: 'Microsoft Yahei'; ">生成证书:</span></div><div style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 13px; line-height: 18px; "><span style="font-family: 'Microsoft Yahei'; ">执行以下openssl命令你就可以为自己生成私人证书</span></div><div style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 13px; line-height: 18px; "><span style="font-family: 'Microsoft Yahei'; ">首先到你想要生成证书和私人密钥的目录,比如</span></div><div style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 13px; line-height: 18px; "><pre><span style="font-family: 'Microsoft Yahei'; ">$ cd /usr/local/nginx/conf</span></pre><p><span style="font-family: 'Microsoft Yahei'; ">现在你可以生成服务器私人密钥,有需要为它设置一个密码</span></p><pre><span style="font-family: 'Microsoft Yahei'; ">$ openssl genrsa -des3 -out server.key 1024 </span></pre><p><span style="font-family: 'Microsoft Yahei'; ">生成证书请求文件</span></p><pre><span style="font-family: 'Microsoft Yahei'; ">$ openssl req -new -key server.key -out server.csr </span></pre><p><span style="font-family: 'Microsoft Yahei'; ">移除用上面的私人密钥启动ngingx ssl加密时必须输入密码的问题</span></p><pre><span style="font-family: 'Microsoft Yahei'; ">$ cp server.key server.key.org</span></pre><pre>$ openssl rsa -in server.key.org -out server.key</pre><p><span style="font-family: 'Microsoft Yahei'; ">最后用上面的私人密钥和证书请求文件签署证书</span></p><pre><span style="font-family: 'Microsoft Yahei'; ">$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt</span></pre></div><div style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 13px; line-height: 18px; "><div>&nbsp;然后再nginx的配置文件的listen 80后面加入下面三行证书和key的名字请改成你自己生成的名字</div><div>server</div><div>&nbsp; &nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; listen &nbsp; &nbsp; &nbsp; 80;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;listen 443 default_server ssl;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ssl_certificate /usr/local/nginx/conf/server.crt;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ssl_certificate_key /usr/local/nginx/conf/server.key;</div></div><div style="color: rgb(34, 34, 34); font-family: sans-serif; font-size: 13px; line-height: 18px; ">之后修改wordpress目录下的wp-config.php在<pre>require_once(ABSPATH . 'wp-settings.php');</pre><p>之前,加</p><pre>define('FORCE_SSL_ADMIN', true);</pre><p>就能使得后台强制加密了;<br />而加入一行</p><pre>define('FORCE_SSL_LOGIN', true);</pre><p>就可以使登录页面强制加密了~</p><p>&nbsp;</p><p>然后重新启动nginx</p></div>
2012-05-08 14:51:48 来自:球球
用户评论(0)
正序阅读
你的回应
登录 | 注册