phpStudy环境安装SSL证书教程

第一步:修改apache目录下的httpd.conf配置文件(D:phpStudyPHPTutorialApacheconf )

#LoadModule ssl_module modules/mod_ssl.so   删除行首的配置语句注释符号“#”

#Include extra/httpd-ssl.conf         将这行的注释的“#”去掉

第二步:编辑xtra/httpd-ssl.conf文件,修改如下内容(D:phpStudyPHPTutorialApacheconfextra):

ServerName    后面改成你的网站域名,可以不带端口号
DocumentRoot    后面改成网站路径
SSLCertificateFile    后面改成server.crt文件路径
SSLCertificateKeyFile    后面改成server.key文件路径
SSLCertificateChainFile    后面改成ca.crt文件路径
ErrorLog    这行开头的可以注释掉(前面加#号)
TransferLog    这行开头的可以注释掉(前面加#号)
CustomLog    这行开头的可以注释掉(前面加#号)

三、依次打开phpstudy安装文件,打开D:phpStudyPHPTutorialApacheconf,在conf文件夹中创建一个名为vhosts_ssl.conf的配置文件。

注意:查看ssl文件夹,里是否存在默认的证书,这是phpstudy默认给的本地证书。

编辑vhosts_ssl.conf文件,增加如下内容:

Listen 443
SSLStrictSNIVHostCheck off
SSLCipherSuite AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL
SSLProtocol all -SSLv2 -SSLv3
<VirtualHost *:443>
    DocumentRoot "D:phpStudyPHPTutorialWWW"
    ServerName 127.0.0.1
    ServerAlias 127.0.0.1
  <Directory "D:phpStudyPHPTutorialWWW">
      Options FollowSymLinks ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
      Require all granted
  </Directory>
  SSLEngine on
  SSLCertificateFile "D:phpStudy\PHPTutorialApacheconfsslserverone.crt"
  SSLCertificateKeyFile "D:phpStudy\PHPTutorialApacheconfsslserverone.key"
</VirtualHost>

这时重启一下phpstudy,如果成功即可,若还是不成功,打开高级安全防火墙将占用443端口的入站规则关闭即可成功!

hostpd.conf里加

#原内容
Include conf/vhosts.conf
#新加的
Include conf/vhosts_ssl.conf

 参考https://blog.csdn.net/weng_xianhu/article/details/83003798

https://blog.csdn.net/qq_33273556/article/details/85279900

https://blog.csdn.net/u010913414/article/details/80685684

https://zhidao.baidu.com/question/430660062050823932.html

待测试:

2.phpstudy配置指定路径访问https(仅供参考,可以不用)

RewriteEngine on

RewriteBase /

RewriteCond %{SERVER_PORT} !^443$

RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

第三步:保存退出,并重启Apache, 若有报错或者无法正常启动,请看错误日志。

参考:http://phpstudy.php.cn/jishu-php-2958.html

原文地址:https://www.cnblogs.com/chenxi188/p/10792647.html