2017-03-27 5 views
0

분리 된 폴더에 여러 버전이있는 프로젝트 하나에 대해 ningx 서버 파일을 설정하려고합니다. 나는 다른 개념과 솔루션을 많이 읽었지만 아무 것도 얻지 못했습니다. 정확히 무엇이 정확한지 모르겠습니다. ...여러 Yii2 고급 프로젝트 위치에 대한 Nginx 구성 (배포 개발)

다른 기능을 갖춘 API를 개발하면서도 훌륭한 아키텍처를 구축하는 것이 목적입니다. 처럼, 아직 우리의 DEV 지점에 병합하지 않으 :

  • api.example.com/v1/user/auth (DEV)
  • api.example.com/ 기능/내 - new-branch/v1/user/auth (새로운 내점)

1. 구조

/var/www/html/project-api/ 
    /dev/ 
     api/ <- Advanced Yii2 Environment as frontend/backend 
     modules/ 
      v1/ 
      controllers/ 
      models/ 
     web/ 
      index.php 
     common/ 
     vendor/ 
     ... 

    /my-new-branch/ 
     api/ 
     modules/ 
      v1/ 
      controllers/ 
      models/ 
     web/ 
      index.php 
     common/ 
     vendor/ 
     ... 
    /*/ <- Deploying more equal branches for in progress features 

2 Nginx에

server { 
    listen 80; 

    root /var/www/html/project-api/src/api/web; 
    index index.php index.html index.htm; 

    server_name api.example.com; 

    error_log /var/log/nginx/project-api/dev-error.log notice; 
    access_log off; 

    location/{ 
     try_files $uri $uri/ /index.php$is_args$args; 
    } 

    ## Features (not working) 
    location ~* ^/features/my-new-branch/(.+)$ { 
     root /var/www/html/project-api/my-new-branch/api/web; 
     try_files /api/web/$1 /api/web/$1/ /features/my-new-branch/index.php?$args; 
     index /features/my-new-branch/$1/index.php; 

     location ~ /\.(ht|git) { 
     deny all; 
     } 

     location ~ \.php$ { 
     try_files $uri =404; 

     fastcgi_param SCRIPT_FILENAME $document_root/api/web/$1; 
     fastcgi_pass unix:/var/run/php/php-fpm.sock; 

     include fastcgi_params; 
     } 
    } 
    ########### 

    # redirect server error pages to the static page /50x.html 
    # 
    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
     root /usr/share/nginx/html; 
    } 

    # pass the PHP scripts to FastCGI server listening on socket 
    # 
    location ~ \.php$ { 

     try_files $uri =404; 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass unix:/var/run/php-fpm.sock; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_param SCRIPT_NAME $fastcgi_script_name; 
     fastcgi_index index.php; 

     include fastcgi_params; 
    } 

    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ { 
     access_log  off; 
     log_not_found  off; 
     expires   30d; 
    } 

    # deny access to . files, for security 
    # 
    location ~ /\. { 
     log_not_found off; 
     deny all; 
    } 
} 

내가 정상 PHP는 웹 사이트와 같은 내 개발 분기를 제공하는 현재의 서버 구성을 가지고 있지만, 나는 좋은 발견하지 여러 뿌리와 공용 폴더 (웹)에이 구조를 가진 여러 PHP 프로젝트 nginx 용 솔루션.

모든 솔루션? 별칭, 루트, , sublocations ..?

(나중에) 내가 프로젝트 폴더에 새로운 기능을 구축,이 동적으로 만들기 위해 변수로 우리의 "내 새로운 분기"을 가지고 좋은 것입니다.

감사

답변

0

당신은 별명, 루트, 하위 공간에서 DAV 또는 분리 위치를 사용할 수 있습니다. 나는 재 작성이 필요 없다고 생각한다.

나는 이것을 Yii2 기본 모듈과 모듈로하고 싶습니다. 하나의 진입 점과 Yii2-app-basic urlMenager가 모든 작업을 수행합니다. 이 당신을 도울하지만 설정 파일을 변경할 필요가-고급 Yii2 - 응용 프로그램 내 새로운 분기를 하위이 Yii2 NGINX advanced config

볼 것이다 경우 는 모르겠지만,

return [ 
    'homeUrl' => '/features/my-new-branch/', 

    'components' => [ 

     'request' => [ 
      'baseUrl' => '/features/my-new-branch', 
     ], 
    ] 
]