1、打开phpstudy-》其他选项菜单-》PHP扩展-》php-openssl前面勾选上。
2、在Apache的安装目录下创建任意目录,并且将下载的证书文件放到该文件夹中。
3、打开 Apache 安装目录下 conf 目录中的 httpd.conf 文件,找到LoadModule ssl_module modules/mod_ssl.so并去掉前面的“#”注释符
4、搜索Include conf/vhosts.conf,在其下面增加一条引用内容:Include conf/vhoststp.conf
5、在Apache 安装目录下 conf
文件夹中创建一个vhoststp.conf配置文件(vhoststp.conf必须和应用的文件名相同)。vhoststp.conf文件中的所有内容如下所示:
Listen 443
<VirtualHost shop.niumhot.com:443>
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile "D:\phpStudy\Apache\cert\xxx.cer"
SSLCertificateKeyFile "D:\phpStudy\Apache\cert\xxx.key"
SSLCertificateChainFile "D:\phpStudy\Apache\cert\xxx_ca.crt"
DocumentRoot "D:\web\tsb" //程序目录
<Directory />
Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
6、重庆apache生效、
7、http 自动跳转到https 在程序根目录下的.htaccess尾巴添加以下代码
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
发表评论