ios在线安装的步骤简单来说就是部署一台https文件服务器(Nginx),生成好openssl证书,将app用AdHoc或者企业版本证书签名。这样用户只需要通过Safari访问页面就可以安装了。 这里要说明一下,使用企业版本证书签名的app是不能够上传到app store上面的,但是任何设备都可以下载安装该app。 通过AdHoc签名的app需要终端用户设备的udid加入到该签名的.mobileprovision中才能安装。没有加入udid的用户是不能够安装的。

具体步骤如下:

1、部署一台https服务器。这里我们使用的是Nginx(也可以使用Apache的httpd)。注意必须要是https的服务器,否则无法启动iOS的安装功能。

安装Nginx在Linux上可以参考这里,需要安装一些依赖库(如pcre)。

openssl需要0.9.8的版本,不要1.0的版本。Nginx的编译配置如下:

./configure --with-http_ssl_module --with-openssl=../openssl-0.9.8zh  
make  
make install  

2、Nginx的配置如下(关键看https的部分)

user  root;  
worker_processes  1;  
  
#error_log  logs/error.log;  
#error_log  logs/error.log  notice;  
#error_log  logs/error.log  info;  
  
#pid        logs/nginx.pid;  
  
  
events {  
    worker_connections  1024;  
}  
  
  
http {  
    include       mime.types;  
    default_type  application/octet-stream;  
  
    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '  
    #                  '$status $body_bytes_sent "$http_referer" '  
    #                  '"$http_user_agent" "$http_x_forwarded_for"';  
  
    #access_log  logs/access.log  main;  
  
    sendfile        on;  
    #tcp_nopush     on;  
  
    #keepalive_timeout  0;  
    keepalive_timeout  65;  
  
    #gzip  on;  
  
    server {  
        listen       80;  
        server_name  127.0.0.1;  
  
        #charset koi8-r;  
  
        #access_log  logs/host.access.log  main;  
  
        location /ios_test {  
                root   /mnt/langresser/download/;  
                index  index.html index.htm;  
        }  
  
    location /ipa_test {  
        alias /mnt/langresser/download/;  
        add_header Content-Dispositoin "attachment";  
    }  
        #error_page  404              /404.html;  
  
        # redirect server error pages to the static page /50x.html  
        #  
        error_page   500 502 503 504  /50x.html;  
        location = /50x.html {  
            root   html;  
        }  
  
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80  
        #  
        #location ~ \.php$ {  
        #    proxy_pass   http://127.0.0.1;  
        #}  
  
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000  
        #  
        #location ~ \.php$ {  
        #    root           html;  
        #    fastcgi_pass   127.0.0.1:9000;  
        #    fastcgi_index  index.php;  
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;  
        #    include        fastcgi_params;  
        #}  
  
        # deny access to .htaccess files, if Apache's document root  
        # concurs with nginx's one  
        #  
        #location ~ /\.ht {  
        #    deny  all;  
        #}  
    }  
  
  
    # another virtual host using mix of IP-, name-, and port-based configuration  
    #  
    #server {  
    #    listen       8000;  
    #    listen       somename:8080;  
    #    server_name  somename  alias  another.alias;  
  
    #    location / {  
    #        root   html;  
    #        index  index.html index.htm;  
    #    }  
    #}  
  
  
    # HTTPS server  
    #  
    server {  
        listen       443 ssl;  
        server_name  127.0.0.1;  
    ssl on;  
        ssl_certificate      /usr/local/nginx/conf/server.crt;  
        ssl_certificate_key  /usr/local/nginx/conf/server_nopwd.key;  
    #autoindex on;  
    #autoindex_exact_size off;        
  
    location /ios {  
                root   /mnt/langresser/download/;  
        index index.html index.htm;  
    }  
  
    location /ipa {  
        alias /mnt/langresser/download/;  
        add_header Content-Dispositoin "attachment";  
    }  
  
}  
    #    ssl_session_cache    shared:SSL:1m;  
    #    ssl_session_timeout  5m;  
  
    #    ssl_ciphers  HIGH:!aNULL:!MD5;  
    #    ssl_prefer_server_ciphers  on;  
  
    #    location / {  
    #        root   html;  
    #        index  index.html index.htm;  
    #    }  
    # }  
  
}  

3、ipa生成的时候会同时生成一个manifest.plist。这个要进行一些修改,主要是服务器ip地址。例子如下:

<?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://127.0.0.1/ipa/thirtysix.ipa</string>  
                </dict>  
                <dict>  
                    <key>kind</key>  
                    <string>display-image</string>  
                    <key>url</key>  
                    <string>https://127.0.0.1/ipa/thirtysix57.png</string>  
                </dict>  
                <dict>  
                    <key>kind</key>  
                    <string>full-size-image</string>  
                    <key>url</key>  
                    <string>https://127.0.0.1/ipa/thirtysixfull.png</string>  
                </dict>  
            </array>  
            <key>metadata</key>  
            <dict>  
                <key>bundle-identifier</key>  
                <string>com.jzsj.thirtysix</string>  
                <key>bundle-version</key>  
                <string>1.0</string>  
                <key>kind</key>  
                <string>software</string>  
                <key>title</key>  
                <string>三十六计</string>  
            </dict>  
        </dict>  
    </array>  
</dict>  
</plist>  

4、一个测试页面如下(index.html,配置在nginx中)

<!DOCTYPE html>  
<html>  
<head>  
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
  <title>游戏Demo</title>  
</head>  
<body>  
<h1>1. iOS安装 <a href="https://127.0.0.1/ipa/server.crt">证书</a><br/>(如果之前尚未安装过此证书,请先安装证书)</h1>  
<br/>  
<h1>2. iOS安装 <a href="itms-services://?action=download-manifest&url=https://127.0.0.1/ipa/manifest.plist">游戏包</a></h1>  
<br/>  
<h1>3. Android安装 <a href="https://127.0.0.1/ipa/thirtysix.apk">游戏包</a></h1>  
</body>  
</html>  

5、经过如上配置,就部署完一个Nginx服务器,用户在Safari中访问对应的ip地址(注意要通过https来访问,不要直接输入ip地址,因为默认是http)就可以看到index.html页面。用户先安装并信任证书(https的证书),然后点击对应的链接可以调用操作系统的服务来自动下载安装应用。