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 ...
随机推荐
- 错误:Caused by:org.apache.spark.SparkException: Kryo serialization failed: Buffer overflow.Available: 0, required: 21. To avoid this,
这个是写入Redis时用的序列化器,然后错误提示是超过了大小限制,把配置调大即可. .set("spark.kryoserializer.buffer.max","128 ...
- <摘录>MBR和分区表
MBR 意思是主引导记录.位于硬盘的0柱面.0磁头.1扇区. MBR 大小为1个扇区,512字节. 下面是MBR的结构: 偏移 构 ...
- [HTML/CSS]z-Index层重叠顺序
目录 语法结构 如何使用? 使用案例 总结 语法结构 z-index:具体数字.如:div{z-index:100},注意,后面跟的数字并不带单位.主要应用在div,span等标签的层叠处理. 如何使 ...
- 【mysql】mysql增加version字段实现乐观锁,实现高并发下的订单库存的并发控制,通过开启多线程同时处理模拟多个请求同时到达的情况 + 同一事务中使用多个乐观锁的情况处理
mysql增加version字段实现乐观锁,实现高并发下的订单库存的并发控制,通过开启多线程同时处理模拟多个请求同时到达的情况 ==================================== ...
- Linux下启动和停止Java应用程序的Shell脚本
转自:http://blog.csdn.net/jadyer/article/details/7960802 资料参考来源自兔大侠,并略作修改:http://www.tudaxia.com/archi ...
- Quartz_TimeJob例子(C#)
执行入口: using System; using System.Collections.Generic; using log4net; using Quartz; using ypt_base.Co ...
- Kali 2.0安装与使用指南
阅读目录 (1)如果坚持用系统自带浏览器,其汉化方法: (2)如果有强迫症删了系统自带浏览器,然后重新安装了一个新的火狐可能遇到的问题: (3)如果你有火狐账号,你登陆了发现书签和插件没有同步? (4 ...
- 阿里云ECS主机内核调优
#阿里云内核调优 cat /etc/sysctl.conf vm.swappiness = 0net.ipv4.neigh.default.gc_stale_time=120 # see detail ...
- (转)Android项目重构之路:架构篇
去年10月底换到了新公司,做移动研发组的负责人,刚开始接手android项目时,发现该项目真的是一团糟.首先是其架构,是按功能模块进行划分的,本来按模块划分也挺好的,可是,他却分得太细,总共分为了17 ...
- What is required for a successful backup of all files during hoi backup?
There is a typo in the body of this question. It should be "Hot" instead of "hoi" ...