2013-08-06 3 views
9

AWS Opsworks에서 사용자 정의 레이어를 사용하여 nginx 웹 서버를 추가하려고합니다.AWS Opsworks 사용자 정의 레이어 배치

성공적으로 레이어를 만들었으므로 GIT (repo에 비밀번호 없음)를 통해 앱을 추가했지만 명령을 배포 할 때 "성공"했지만 내 서버에는 내 코드가 표시되지 않습니다.

사용자 지정 계층에서 유일한 배포 방법은 "배포 :: 기본값"입니다.

배포를 처리하기 위해 사용자 지정 래서 피가 필요합니까?

또한 어떻게 배치를 "어디에"구성합니까? 나는 Opsworks가 그렇지 않으면 항상 배치 할 것으로 보이는 위치를 사용하는 대신 내 문서 루트를 선택하기를 원합니다.

어떤 도움을 주셔서 감사합니다.

답변

1

예. 맞춤 레이어에 대해 고유 한 맞춤 배포 레시피를 작성해야합니다. 배포 방법은 배포 위치와 소프트웨어 배포에 필요한 단계를 구성 할 수 있습니다. 또는 Nginx를 배포하는 OpsWorks 정적 웹 서버 계층을 확장하여 필요에 맞게 확장 할 수 있습니다.

13

나는 Opsworks nginx 제조법을 사용하여 응용 프로그램을 완전히 자동으로 배포하는 간단한 방법을 작성했습니다. 구성된 SCM에서 체크 아웃하고, 새로운 nginx 가상 호스트를 만들고 필요하면 nginx를 다시로드합니다.

레이어에 배포 설정이 조리법을 추가

deploy.rb

include_recipe "deploy" 
include_recipe "php5" 

node[:deploy].each do |application, deploy| 

    Chef::Log.info("Deploying application #{application} on #{node[:opsworks][:instance][:hostname]}") 

    if deploy[:application_type] != 'php' 
    Chef::Log.warn("Skipping deploy::web application #{application} as it is not a PHP app") 
    next 
    end 

    opsworks_deploy_dir do 
    user deploy[:user] 
    group deploy[:group] 
    path deploy[:deploy_to] 
    end 

    opsworks_deploy do 
    app application 
    deploy_data deploy 
    end 

    nginx_web_app application do 
    application deploy 
    end 

    Chef::Log.info("Running composer update on #{deploy[:deploy_to]}") 
    composer_update do 
    path deploy[:deploy_to]} 
    end 
end 

의 nginx 가상 호스트 서식 파일을 덮어 쓰려면, 단지 nginx라는 새로운 요리 책을 만들고 파일을 추가 site.erbtemplates/default. Opsworks는이 템플릿을 자동으로 사용합니다.

내 site.erb는 배포 애플리케이션 서버 :: 배포를위한 요리 책에 (작곡가)이

server { 
    listen 80; 
    server_name <%= @application[:domains].join(" ") %> <%= node[:hostname] %>; 
    access_log <%= node[:nginx][:log_dir] %>/<%= @application[:domains].first %>.access.log; 

    root <%= @application[:absolute_document_root] %>; 

    location/{ 
    try_files $uri /index.php?url=$uri&$args; 
    } 

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

     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 

     include fastcgi_params; 
    } 

    # Block all svn access 
    if ($request_uri ~* ^.*\.svn.*$) { 
    return 404; 
    } 

    # Block all git access 
    if ($request_uri ~* ^.*\.git.*$) { 
    return 404; 
    } 

    location /nginx_status { 
    stub_status on; 
    access_log off; 
    allow 127.0.0.1; 
    deny all; 
    } 

} 

<% if @application[:ssl_support] %> 
server { 
    listen 443; 
    server_name <%= @application[:domains].join(" ") %> <%= node[:hostname] %>; 
    access_log <%= node[:nginx][:log_dir] %>/<%= @application[:domains].first %>-ssl.access.log; 

    ssl on; 
    ssl_certificate <%= node[:nginx][:dir] %>/ssl/<%= @application[:domains].first %>.crt; 
    ssl_certificate_key <%= node[:nginx][:dir] %>/ssl/<%= @application[:domains].first %>.key; 
    <% if @application[:ssl_certificate_ca] -%> 
    ssl_client_certificate <%= node[:nginx][:dir] %>/ssl/<%= @application[:domains].first %>.ca; 
    <% end -%> 

    location/{ 
    try_files $uri /index.php?url=$uri&$args; 
    } 

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

     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 

     include fastcgi_params; 
    } 

    # Block all svn access 
    if ($request_uri ~* ^.*\.svn.*$) { 
    return 404; 
    } 

    # Block all git access 
    if ($request_uri ~* ^.*\.git.*$) { 
    return 404; 
    } 
} 
<% end %> 

내 Berksfile처럼

source "https://supermarket.getchef.com" 

cookbook 'composer', '~> 1.0.4' 

내 metadata.rb를 찾습니다 조리법

name    'appserver' 
maintainer  'Michel Feldheim' 
description  'Setting up the appserver environment' 
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 
version   '0.1.0' 

depends   "nginx" 
depends   "php5" 
+6

질문에 매우 자세히 대답 할 때 정말 짜증나지만 대답은 받아 들여지지 않으며 간단히 말해서 '고맙습니다.' 음 .. 다른 SOF 사용자를 대신해 주셔서 감사합니다. – scaryguy

관련 문제