/cookbooks/nginx/recipes/default.rb
# Cookbook Name:: nginx # Recipe:: default # # Copyright 2013, YOUR_COMPANY_NAME # # All rights reserved - Do Not Redistribute # 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.con" source "nginx.conf.erb" owner "root" group "root" mode 0644 notifies :reload , 'service[nginx]' end
cookbooks/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/mime.types;
default_type application/octet-stream;
server {
listen <%= node['nginx']['port'] %>;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
}
}localhost.json
// localhost.json
{
"nginx" : {
"port" : 80
},
"run_list" : [
"nginx"
]
}