phpstudy配置https,开启httpd-ssl.conf,Apache就启动不了的原因

前几天公司的网站需要升级https,网上有很多教程详细描述了怎么在phpstudy上面配置https,自己也是按照这些教程一步一步来的,但是复制文件到httpd-ssl.conf,Apache就启动不了,出现这个的原因肯定是复制的内容有错误,有错误的地方很大一部分就是在引用证书那一部分,一定要注意检查,证书是否真正的被引入。

下方是我的httpd-ssl.conf文件内容:

Listen 443
<VirtualHost *:443>
    DocumentRoot "项目路径" //这个项目路径用的这个'\'斜杠
    ServerName 域名
    ServerAlias 域名
    SSLEngine on
    SSLProtocol TLSv1 TLSv1.1 TLSv1.2
    SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
    SSLCertificateFile "D:/phpStudy/PHPTutorial/Apache/conf/ssl/1p.crt"  // 公钥(文件名中有public),引用证书要用'/'这个斜杠
    SSLCertificateKeyFile "D:/phpStudy/PHPTutorial/Apache/conf/ssl/2.key"// 私钥, 引用证书要用'/'这个斜杠
    SSLCertificateChainFile "D:/phpStudy/PHPTutorial/Apache/conf/ssl/3c.crt"//根证书(文件名有chain),  引用证书要用'/'这个斜杠
<Directory "项目路径">
      Options +Indexes +FollowSymLinks +ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
      Require all granted
  </Directory>
</VirtualHost>

配置好httpd-ssl.conf,可以用phpstudy自带的cmd命令行检测下,是否能启动
进入Apache\bin目录输入httpd.exe -t 检查是否有错。

最后在项目目录建立一个无后缀的.htaccess文件,以下是内容
 

RewriteEngine on

RewriteBase /

RewriteCond %{SERVER_PORT} !^443$

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

猜你喜欢

转载自blog.csdn.net/qq_33273556/article/details/85279900