码迷,mamicode.com
首页 > Web开发 > 详细

在mac Apache配置https方式访问网站

时间:2015-03-18 14:14:58      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

  1. 引入httpd-ssl.conf文件

    在相应的目录下找到httd-conf文件  一般都是在/etc/apache2/httpd.conf  下 

    取消掉Include /private/etc/apache2/extra/httpd-ssl.conf 前面的注释符号#  也就是引入httpd-ssl.conf文件

  2. 生成KEY和证书。

    因为在 /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

  3. 重启Apache  

    sudo  apachectl restart

    反问 https:localhost便能进入相应页面

配置站点
(1)在httpd-ssl.conf文件头部添加  NameVirtualHost *:443
(2)在文件底部添加类似下面配置 即可
<VirtualHost *:443>
    DocumentRoot "path_to_your_projects"
    ServerName localhost.xxx
    ErrorLog "/private/var/log/apache2/xxx-error_log"
	TransferLog "/private/var/log/apache2/xxx-access_log"
	SSLEngine on
	SSLCertificateFile "/private/etc/apache2/server.crt"
	SSLCertificateKeyFile "/private/etc/apache2/server.key"
</VirtualHost>
注意:一般来所 SSLCertificateFile 和SSLCertificateKeyFile的地址用默认的就好 但是配置过程当中如果出现问题 可以留意是不是 他们的地址出现问题了

  大功告成!! 

Linux 系统应该也是这样 。。windows 有待研究






在mac Apache配置https方式访问网站

标签:

原文地址:http://my.oschina.net/u/1040928/blog/388339

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!