引入httpd-ssl.conf文件
在相应的目录下找到httd-conf文件 一般都是在/etc/apache2/httpd.conf 下
取消掉Include /private/etc/apache2/extra/httpd-ssl.conf 前面的注释符号# 也就是引入httpd-ssl.conf文件
生成KEY和证书。[mac下] 【windows xamp 下不需要】
因为在 /private/etc/apache2/extra/httpd-ssl.conf 已经配置好KEY 和证书的名字所以下面的步骤中请不要修改生成的KEY文件的名字 如果修改请把httpd-ssl.conf中相应的文件路径和名字也修改
cd /etc/apache2
(1) sudo openssl genrsa -des3 -out server.key 1024
enter a passphrase for your private key. (输入key 的密码在接下来的过程中会用到,随意输入123456) ;
(2) openssl req -new -key server.key -out server.csr
接下来的省城市email等等选项可以留空 即按enter 键进入下一步
(3) sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
(4)备份
cp server.key server.key.copy
openssl rsa -in server.key.copy -out server.key
重启Apache
sudo apachectl restart
反问 https:localhost便能进入相应页面
配置站点(1)在httpd-ssl.conf文件头部添加 NameVirtualHost *:443(2)在文件底部添加类似下面配置 即可DocumentRoot "path_to_your_projects" ServerName localhost.xxx ErrorLog "/your_log_path/apache2/xxx-error_log" TransferLog "/your_log_path/apache2/xxx-access_log" SSLEngine on 【mac环境下使用这个】 SSLCertificateFile "/private/etc/apache2/server.crt" SSLCertificateKeyFile "/private/etc/apache2/server.key" 【win环境下使用这个】 SSLCertificateFile "conf/ssl.crt/server.crt" SSLCertificateKeyFile "conf/ssl.key/server.key"注意:一般来说 SSLCertificateFile 和SSLCertificateKeyFile的地址在httpd-sll.conf 都有默认地址。我们尽量不去修改他
大功告成!!
以上步骤 mac下 是全部要执行
windows【博主是在xamp环境测试的 其他环境的 自行测试】下 不需要第二步 其他的需要