Skip to content

Instantly share code, notes, and snippets.

@atsuya046
Created December 31, 2013 14:44
Show Gist options
  • Save atsuya046/8197807 to your computer and use it in GitHub Desktop.
Save atsuya046/8197807 to your computer and use it in GitHub Desktop.
custom cookbook for install and setting nginx
#repo/Berkshelf
cookbook 'nginx', '~> 0.1.0', path: 'site-cookbooks/nginx'
#site-cookbook/nginx/recipes/default.rb
package "nginx" do
action :install
end
service "nginx" do
supports :status => true, :restart => true, :reload => true
action [:enable, :start]
end
template "nginx.conf" do
path "/etc/nginx/nginx.conf"
source "nginx.conf.erb"
owner "root"
group "root"
mode 0644
notifies :reload, "service[nginx]"
end
#site-cookbook/nginx/templates/default/nginx.conf.erb
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mim.types;
default_type application/octet-stream;
server {
listen <%= node["nginx"]["port"] %>;
server_name _;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
}
#repo/Vagrantfile
...
chef.add_recipe "nginx"
...
chef.json = {
...,
"nginx" => {
"port" => 3000,
}
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment