どのようにしてアプリケーションのバージョン別の展開ができますか?

2064 ワード

説明
仕事の中で、私達のソフトウェアは絶えず進級しています。例えば、今はv 0.4バージョンですが、後でv 0.5にアップグレードします。その時、私達は2時を保証します。
  • はバージョンなしでアクセスした時、最新バージョンにアクセスしました。
  • バージョンでアクセスすると、指定されたバージョンのサービスにアクセスします。
  • 例えば、v 0.5にアクセスすると、v 0.5に調整できるプログラムです。古いv 0.4を訪問する時、訪問したのはv 0.4バージョンです。
    ここで簡単に説明します。
    設定
    ここは比較的に怠惰で、直接copy!
    server {
            listen       80;
            server_name  api.m.example.com;
            charset utf-8;
            root   /home/app/api.m.example.com/v0.5/web/;   #    ,      v0.5。     ,         v0.5。
    
            location / {
                index  index.php index.html index.htm;    #    index  
            }
    
            #   /v0.4/     ,  /home/app/api.m.example.com/v0.4/web/
            location /v0.4/ {
                index index.php;
                alias /home/app/api.m.example.com/v0.4/web/; 
            } 
            #   v0.4   ,  /home/app/api.m.example.com/v0.4/web/    index.php    
            location ~ ^/v0.4/(.*\.php)$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  /home/app/api.m.example.com/v0.4/web/$1; 
                include        fastcgi_params;
            }
    
            location /v0.5/ {
                index index.php;
                alias /home/app/api.m.example.com/v0.5/web/;
            }
            location ~ ^/v0.5/(.*\.php)$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  /home/app/api.m.example.com/v0.5/web/$1;
                include        fastcgi_params;
            }
    
            #           ,           location,          
            location ~ \.php$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
            }
    
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    
            access_log /home/logs/api.m.example.com/access.log access;
            error_log /home/logs/api.m.example.com/error.log info;
        }