mac 使用apache开启https功能,实现ios局域网内测(一)
笔者尝试了网上各种办法最后还是找到了方法解决了一系列局域网内测的问题,随手做个笔记记录下,亲测可行。
一、先生成证书
1、进入apache web 的根目录处理证书命令
cd /Library/WebServer/Documents/ios
基于 /Library/WebServer/Documents/ios 根目录下处理命令:
a-生成私钥,命令: sudo openssl genrsa -des3 -out app.key 1024
b-生成签署申请,命令: sudo openssl req -new -key app.key -out app.csr
c-生成服务器的私钥,命令: sudo openssl rsa -in app.key -out server.key
d-生成给网站服务器签署的证书,命令: sudo openssl req -new -x509 -days 3650 -key server.key -out server.crt
网摘一位网友的命令处理记录:
zhuruhongdeMacBook-Pro:ios zhuruhong$ sudo openssl genrsa -des3 -out app.key 1024
Generating RSA private key, 1024 bit long modulus
.....++++++
.........++++++
e is 65537 (0x10001)
Enter pass phrase for app.key:[这里是输入密码]
Verifying - Enter pass phrase for app.key:[这里再次输入密码确认]
zhuruhongdeMacBook-Pro:ios zhuruhong$
zhuruhongdeMacBook-Pro:ios zhuruhong$ sudo openssl req -new -key app.key -out app.csr
Enter pass phrase for app.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN[这里是国家,CN中国]
State or Province Name (full name) [Some-State]:hangzhou[这里是省份,城市]
Locality Name (eg, city) []:hangzhou[这里是城市]
Organization Name (eg, company) [Internet Widgits Pty Ltd]:hz ltd[这里是公司]
Organizational Unit Name (eg, section) []:rh[这里是组织名称]
Common Name (e.g. server FQDN or YOUR name) []:192.168.2.1[这个必须填正确,是你的服务器的域名,或者ip]
Email Address []:zhu410289616@163.com[这里是我的邮箱]
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456[这里是密码]
An optional company name []:rh[这里是名字]
zhuruhongdeMacBook-Pro:ios zhuruhong$
zhuruhongdeMacBook-Pro:ios zhuruhong$ sudo openssl rsa -in app.key -out server.key
Enter pass phrase for app.key:[这里输入密码]
writing RSA key
zhuruhongdeMacBook-Pro:ios zhuruhong$
zhuruhongdeMacBook-Pro:ios zhuruhong$ sudo openssl req -new -x509 -days 3650 -key server.key -out server.crt
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:hangzhou
Locality Name (eg, city) []:hangzhou
Organization Name (eg, company) [Internet Widgits Pty Ltd]:hz ltd
Organizational Unit Name (eg, section) []:rh
Common Name (e.g. server FQDN or YOUR name) []:192.168.2.1
Email Address []:zhu410289616@163.com
zhuruhongdeMacBook-Pro:ios zhuruhong$
zhuruhongdeMacBook-Pro:ios zhuruhong$ sudo cp server.* /etc/apache2/
zhuruhongdeMacBook-Pro:ios zhuruhong$
zhuruhongdeMacBook-Pro:apache2 zhuruhong$ sudo apachectl configtest
Syntax OK
zhuruhongdeMacBook-Pro:apache2 zhuruhong$ sudo apachectl restart
2、apache 开启ssl功能
2.1 编辑/etc/apache2/httpd.conf文件,去掉下面四行前面的#号
(/etc/apache2/httpd.conf和/private/etc/apache2/httpd.conf其实是同一个内容)
LoadModule ssl_module libexec/apache2/mod_ssl.so
Include /etc/apache2/extra/httpd-ssl.conf
Include /etc/apache2/extra/httpd-vhosts.conf
LoadModule socache_shmcb_module libexec/apache2/mod_socache_shmcb.so
这里检查ServerName 指向的是什么,如果没有定义,需要加上127.0.0.1:80
2.2 编辑/etc/apache2/extra/httpd-ssl.conf文件,去掉下面两行前面的#号
SSLCertificateFile "/etc/apache2/ssl/server.crt"
SSLCertificateKeyFile "/etc/apache2/ssl/server.key"
说明(因为命令 sudo cp server.* /etc/apache2/ 只是拷贝到Apache2目录下,而httpd-ssl.conf SSLCertificateFile默认指向ssl文件夹的,要不在Apache2下创建ssl文件夹把server.crt和server.key放在ssl,要不修改SSLCertificateFile 和 SSLCertificateKeyFile /etc/apache2/server.crt ,/etc/apache2/ssl/server.key )
2.3 编辑/etc/apache2/extra/httpd-vhosts.conf文件
<VirtualHost *:80>
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /etc/apache2/server.crt
SSLCertificateKeyFile /etc/apache2/server.key
ServerName 192.168.4.247
DocumentRoot "/Library/WebServer/Documents"
</VirtualHost>
说明:可以把原来<VirtualHost *:80></VirtualHost>的内容注释了,把这个粘贴进去 注意:ServerName 是你服务器的ip(如果是本机最好输入局域网的ip不要输入127.0.0.1),SSLCertificateFile 和SSLCertificateKeyFile 与上面2.2 步骤的路径要对应。
到这里就配置完成了,运行sudo apachectl configtest命令,检查配置。
Syntax OK 代表成功
可以重启服务器 sudo apachectl restart
到这里服务器就已经支持ssl了,可以访问https://ip/ios了
这里补充一点,更换Apache 的根目录
1.需要修改 httpd.conf文件

2.修改 httpd-vhosts.conf

3.修改httpd-ssl.conf

重启Apache 就可以了
如果遇到没有权限访问
再修改httpd.conf文件

mac 使用apache开启https功能,实现ios局域网内测(一)的更多相关文章
- mac 使用apache开启https功能,实现ios局域网内测(二)
二.创建app.plist 1. <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist ...
- Linux下Apache配置HTTPS功能
Apache配置HTTPS功能 转 https://www.cnblogs.com/liaojiafa/p/6028816.html 一.yum 安装openssl和openssl-devel,ht ...
- OpenSSL证书生成及Mac上Apache服务器配置HTTPS(也适用centos)
自签名证书 配置Apache服务器SSL 自己作为CA签发证书 这里是OpenSSL和HTTPS的介绍OpenSSLHTTPS 开启HTTPS配置前提是已在Mac上搭建Apache服务器→Mac上Ap ...
- Ubuntu下配置apache开启https
一.HTTPS简述随着网络的日常,信息安全越来越重要,传统的网站都是http协议明文传输,而HTTPS协议是由SSL+HTTP协议构建的可进行加密传输.身份认证的网络协议,比http协议安全. 那ht ...
- Apache配置HTTPS功能
apache配置https 一.yum 安装openssl和openssl-devel,httpd-devel 二.生成证书(也可以从公司的证书颁发机构获取): #建立服务器密钥 openssl ge ...
- apache 开启压缩功能
apache如何开启压缩功能. 1,首先先确认是安装deflatte模块.如果未安装,可以重新编译apache添加参数--enable-deflate=shared ,或者扩展安装deflate模块, ...
- Apache开启压缩功能
起源 在一般的web服务器中,都会开启压缩功能,也就是deflate或者是gzip的压缩. 开启压缩功能主要的目的是为了减少传输的带宽,从而当服务器响应给客户端的时候,会大大减少传输的数据,代价就是在 ...
- 腾讯云CentOS Apache开启HTTPS
1.申请SSL证书 https://console.qcloud.com/ssl?utm_source=yingyongbao&utm_medium=ssl&utm_campaign= ...
- Apache 开启 Https
1. 准备所需工具: 1) apache httpd2.4 浏览 2) Win32 OpenSSL v1.0.2d 浏览 2. 安装 2.1 安装Apache2.4服务 php环境搭建 浏览 2.2 ...
随机推荐
- [CODECHEF]RIN
题意:一个人要在$m$个学期上$n$节课,在第$j$学期上$i$课有$X_{i,j}$的收益,有些课$B_i$有前置课程$A_i$,问最大得分 这个题我都做不出来还去看题解...我退役吧== 考虑每种 ...
- 【线段树】XIII Open Championship of Y.Kupala Grodno SU Grodno, Saturday, April 29, 2017 Problem J. Jedi Training
题意:给你一个序列,支持两种操作:单点修改:询问一个区间中所有相邻位置下标奇偶性均不同的子序列中,和最大的是多少. 线段树每个结点维护四个值: 以奇数下标开始到奇数下标结束的最大子序列和: 以偶数下标 ...
- 【Manacher算法】poj3974 Palindrome
Manacher算法教程:http://blog.csdn.net/ggggiqnypgjg/article/details/6645824 模板题,Code 附带注释: #include<cs ...
- 基于socket的udp传输,socketserver模块,进程
基于UDP的套接字 udp是无连接的,先启动哪一端都不会报错 socket.SOCK_DGRAM 数据报协议 udp不会发送空数据,什么都不输入直接发送也会有报头发过去 服务端 import sock ...
- (转载)JavaScript中匿名函数,函数直接量和闭包
首先,我们先看看下面几种写法:1.function f(x){return x*x;};f(x);2.(function(x){return x*x;})(x);3.(function(x){retu ...
- 帝国CMS网站迁移方法
19大学网 我是用帝国CMS 6.0一键安装版的,在本地设计好网页后才上传到空间.期间查看了很多资料,通过两天的摸索终于上传成功,现在我把我的制作过程如实的写下来,希望对遇到同样问题的朋友能有所 ...
- MYSQL复习笔记13-触发器trigger
Date: 20140305Auth: Jin 一.概念1.基本概念触发器是一个被指定关联到一个表的数据对象,触发器是不需要调用的,当对一个表的特别事件出现时,它就被激活.触发器的代码也是由SQL语句 ...
- Java 8:不要再用循环了 Stream替代for循环
原文:http://www.importnew.com/14841.html 在这篇文章里,我们将会去了解传统循环的一些替代方案.在Java 8的新功能特性中,最棒的特性就是允许我们去表达我们想要完成 ...
- nginx服务器URL无法自动添加index.php
请教个nginx问题,添加try_files $uri $uri/index.php /index.php?$query_string;,类似www.mydomain.com/admin这样的URL可 ...
- [Linux] ubuntu 软件安装必须看的网址
http://wiki.ubuntu.org.cn/index.php?title=Qref/Apps&variant=zh-hans 这里介绍了unbuntu常用软件及其安装,免得你百度来百 ...