多语言展示
当前在线:1538今日阅读:61今日分享:18

在Apache安装SSL证书

SSL证书是数字证书的一种,类似于驾驶证、护照和营业执照的电子副本。因为配置在服务器上,也称为SSL服务器证书。SSL 证书就是遵守 SSL协议,由受信任的数字证书颁发机构CA,在验证服务器身份后颁发,具有服务器身份验证和数据传输加密功能。
工具/原料

SSL证书文件

方法/步骤
2

接下来找到Apache\conf目录下的vhosts.conf文件,用记事本打开,把文件代码替换成这个:Listen 443DocumentRoot 'C:\myphp_www\PHPTutorial\WWW\pntourism\public'ServerName www.pntourism.comServerAlias pntourism.comSSLEngine onSSLProtocol all -SSLv2 -SSLv3SSLCipherSuite AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULLSSLCertificateFile 'C:\myphp_www\PHPTutorial\Apache\conf\ssl\2_www.pntourism.com.crt'SSLCertificateKeyFile 'C:\myphp_www\PHPTutorial\Apache\conf\ssl\3_www.pntourism.com.key'SSLCertificateChainFile 'C:\myphp_www\PHPTutorial\Apache\conf\ssl\1_root_bundle.crt' DocumentRoot 'C:\myphp_www\PHPTutorial\WWW\pntourism\public'      Options -Indexes +FollowSymLinks +ExecCGI    AllowOverride All    Order allow,deny    Allow from all    Require all granted 

3

其中C:\myphp_www\PHPTutorial\WWW\pntourism\public对应你thinkphp框架里面的public文件夹位置,请结合自己的实际情况进行设置。

4

有了ssl证书,网站域名的http就要变成https,如果你使用了301重定向的话,那就需要对应进行修改,打开thinkphp框架里面的public文件夹里面的.htaccess文件,将这段代码添加上去,里面原来的代码不要修改它:deny from allRewriteEngine onRewriteCond %{HTTP_HOST} ^(itxsz\.com)(:80)? [NC]RewriteRule ^(.*) https://www.itxsz.com/$1 [R=301,L]RewriteEngine onRewriteBase /RewriteCond %{SERVER_PORT} !^443$RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

5

代码里面的itxsz\.com和www.itxsz.com要替换成你自己的网站域名

6

接下来重启PHP工具箱或者PHPstudy,访问你的域名,就可以看到你网站域名上了一把“锁”。

推荐信息