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 ...
随机推荐
- (疯狂java)第二课
(本文章只是为了好玩,没有别的意思,有理解错误之处,恳请提醒,谢谢) 三.数据类型和运算符 想了一下今天看的内容好像依然大脑停留在用C语言去理解java,感觉有点奇怪,为啥本章叫数据类型和运算符,上来 ...
- BigInt的实现——C++编程风格读书笔记
C++编程风格这本书前面一些章节都觉得很简明易懂,但是读到效率这一章是才充分认识到读别人的代码还是很痛苦的一件事.书中给出的需要改进的初始类如下: class BigInt { private: ch ...
- Base64序列化和反序列化
序列化: Dictionary<string, string> sPara = GetRequestPost(ref parameterStr); string serializeStri ...
- Manthan, Codefest 16 A. Ebony and Ivory 水题
A. Ebony and Ivory 题目连接: http://www.codeforces.com/contest/633/problem/A Description Dante is engage ...
- Linux下KVM的图形界面管理工具(virt-manager)(桌面版)
背景: virt-manager是用于管理KVM虚拟环境的主要工具,virt-manager默认设置下需要使用root用户才能够使用该工具.当你想在KVM hypervisor服务器上托管虚拟机,由最 ...
- 基于 Dapper 的一个 DbUtils
/// <summary> /// v1.0 /// </summary> public partial class DbUtils { string ConnectionSt ...
- file结构体中private_data指针的疑惑
转:http://www.360doc.com/content/12/0506/19/1299815_209093142.shtml hi all and barry, 最近在学习字符设备驱动,不太明 ...
- LaTex:图片排版
一般支持三种格式的图片排版 %% if you use PostScript figures in your article %% use the graphics package for simpl ...
- 判断客户端是PC还是手持设备的JS代码【转】
1.第一种: 复制代码代码如下: function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = [&quo ...
- iOS:延时执行的三种方式
延时执行的三种方式:performSelectorXXX方法.GCD中延时函数.创建定时器 第一种方式:NSObject分类当中的方法,延迟一段时间调用某一个方法 @interface NSObj ...