나는 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.erb
templates/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"
질문에 매우 자세히 대답 할 때 정말 짜증나지만 대답은 받아 들여지지 않으며 간단히 말해서 '고맙습니다.' 음 .. 다른 SOF 사용자를 대신해 주셔서 감사합니다. – scaryguy