1.建立ssl檔案夾
sudo mkdir /private/etc/apache2/ssl
2.切換到ssl檔案夾
cd /private/etc/apache2/ssl
3.生成ssh等檔案相關證書(server.key + server.key.pub)
sudo ssh-keygen -f server.key
4.生成.csr 檔案
sudo openssl req -new -key server.key -out request.csr
注意:Common Name 推薦填寫自己的ip,
5. 生成.crt檔案
sudo openssl x509 -req -days 365 -in request.csr -signkey server.key -out server.crt
結果如下:
6.配置SSL服務
1.)編輯 httpd.conf 檔案
sudo vim /private/etc/apache2/httpd.conf
把以下三行代碼前頭的注釋去掉
LoadModule ssl_module libexec/apache2/mod_ssl.so
Include /private/etc/apache2/extra/httpd-ssl.conf
Include /private/etc/apache2/extra/httpd-vhosts.conf
2.)編輯 httpd-ssl.conf 檔案
sudo vim /private/etc/apache2/extra/httpd-ssl.conf
把以下兩行代碼的注釋去掉
SSLCertificateFile "/private/etc/apache2/server.crt"
SSLCertificateKeyFile "/private/etc/apache2/server.key"
3.)httpd-vhosts.conf 檔案
sudo vim /private/etc/apache2/extra/httpd-vhosts.conf
在末尾添加如下代碼。 内容改成自己的内容。 ServerName 改成自己iP
<VirtualHost *:443>
SSLEngine on
SSLCertificateFile /private/etc/apache2/ssl/server.crt
SSLCertificateKeyFile /private/etc/apache2/ssl/server.key
ServerName 10.2.15.163
DocumentRoot "/Users/lhl/Sites/"
</VirtualHost>
7.測試配置及重新開機Apache
sudo apachectl -t //如果它提示:Syntax OK
sudo apachectl restart
浏覽器輸入 https://10.2.9.163 即可通路成功。
注意如果提示不安全通路,請輕按兩下安裝 server.crt 檔案
8.配置線上安裝app環境
1.)配置plist檔案
code 如下 news.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>https://10.2.15.163/ipa/news.ipa</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>com.sohu.news</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>sohunews</string>
</dict>
</dict>
</array>
</dict>
</plist>
2.配置html檔案
<html>
<head>
<meta charset="utf-8" mime-types="text/plain">
<title> 測試安裝包 </title>
</head>
<body>
<h1>第一次連接配接請先安裝證書,以後就不需要安裝了</h1>
<h2>
證書:<a href="https://10.2.15.163/ipa/server.crt" target="_blank" rel="external nofollow" >profile</a>
</h2>
<h2>HTTPS:<a href="itms-services://?action=download-manifest&url=https://10.2.15.163/ipa/news.plist" target="_blank" rel="external nofollow" >
news-02/13-15:35
</a>
</h2>
</body>
</html>
效果:
最終檔案夾檔案為:
通路 https://10.2.15.163/ipa.html 即可通路安裝應用測試包。
其他:手機也需要先安裝crt證書檔案才可以下載下傳測試包。