mac配置Apache的https
来源:互联网 发布:筛选出的数据求和 编辑:程序博客网 时间:2024/05/17 23:02
mac 配置https
参考:http://www.cnblogs.com/y500/p/3596473.html
证书生成
1.生成主机密钥
这里会要求输入密码,不输入,直接回车
mkdir /private/etc/apache2/sslcd /private/etc/apache2/sslsudo ssh-keygen -f server.key
2.生成证书请求文件
sudo openssl req -new -key server.key -out request.csr
3.生成ssl证书
用上一步生成的文件生成ssl证书
sudo openssl x509 -req -days 365 -in request.csr -signkey server.key -out server.crt
到这里,自签名证书就生成好了,下面就开始配置Apache
配置Apache
4 配置httpd.conf
/private/etc/apache2/httpd.conf ,找到并编辑这个文件去掉下面三行前面的 '#'
LoadModule ssl_module libexec/apache2/mod_ssl.soInclude /private/etc/apache2/extra/httpd-ssl.confInclude/private/etc/apache2/extra/httpd-vhosts.conf
我在第一次配置的时候以为没有mod_ssl.so文件,就专门搜了一次,还brew安装,都找不到,最后发现直接取消#注释就可以,并不需要特意找这个文件
5 配置httpd-ssl.conf
/private/etc/apache2/extra/httpd-ssl.conf,编辑这个文件去掉下面两行前面的 '#'
SSLCertificateFile "/private/etc/apache2/ssl/server.crt"SSLCertificateKeyFile "/private/etc/apache2/ssl/server.key"
这个路径就是刚才生成的证书文件的路径
6 配置httpd-vhosts.conf
/private/etc/apache2/extra/httpd-vhosts.conf ,编辑这个文件在 'NameVirtualHost*:80'后面添加:
NameVirtualHost *:443
其实我电脑上的配置文件没有NameVirtualHost,因此我没有配置这个,最终是可以访问https的
在文件末尾添加:
<VirtualHost *:443> SSLEngine on SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL SSLCertificateFile /private/etc/apache2/ssl/server.crt SSLCertificateKeyFile /private/etc/apache2/ssl/server.key ServerName localhost DocumentRoot "/Library/WebServer/Documents"</VirtualHost>
其中代码中的:DocumentRoot "/Library/WebServer/Documents"是网页路径,我用的是默认的WebServer的Documents
SSLCertificateFile 和SSLCertificateKeyFile与上面的httpd-ssl.conf中的SSLCertificateFile和SSLCertificateKeyFile相同,是自己第一步生成证书的位置
到这里就配置完了,检查配置,没问题的话重启Apache就好了
sudo apachectl configtestsudo apachectl restart
正常的话,就可以用https访问了。
出现的问题:
1 test的时候报错:SSLSessionCache: 'shmcb' session cache not supported
配置好后执行命令
sudo apachectl configtest
得到报错如下:
AH00526: Syntax error on line 92 of /private/etc/apache2/extra/httpd-ssl.conf:SSLSessionCache: 'shmcb' session cache not supported (known names: ). Maybe you need to load the appropriate socache module (mod_socache_shmcb?).
再次执行命令:
sudo apachectl configtest
返回
Syntax OK
restart之后,就可以访问了
https://localhost/
2 vim文件的时候E45: 'readonly' option is set (add ! to override)
文件编辑完成输入:wq之后报错
E45: 'readonly' option is set (add ! to override)
一般这些配置文件都是只读的,需要sudo才可以,我尝试:wq!也是不行的,只能关闭文件,重新打开
如:
sudo vim /private/etc/apache2/httpd.conf
- mac配置Apache的https
- Apache的https配置
- apache的https配置
- MAC下配置Apache服务器支持https
- Mac Apache 配置https(SSL/TLS)
- Mac Apache 配置https(SSL/TLS)
- mac下Apache服务配置Https
- apache的https访问配置
- mac的apache配置
- Mac中开启Apache的Https功能
- 配置apache对 https 的支持
- 在CentOS配置Apache的HTTPS服务
- 在CentOS配置Apache的HTTPS服务
- Apache下https服务的配置
- 阿里云的Apache配置https
- Apache配置https全过程
- Apache配置https全过程
- Apache https 配置指南
- 基础知识总结:枚举
- 基础篇 Android IntentService
- 文章标题
- 正则表达式
- vw 和vh
- mac配置Apache的https
- Git指南之分支
- 小内存(64M)VPS搭建SSR服务器
- socket.error: [Errno 10013] 解决方法
- npm模块安装
- Python学习
- windbg入门教程--视频教程发布
- Visual Studio常用小技巧一:代码段+快捷键+插件=效率
- 保留一篇王牧师的文章