diff --git a/attributes/apache2.rb b/attributes/apache2.rb new file mode 100644 index 0000000..c216da4 --- /dev/null +++ b/attributes/apache2.rb @@ -0,0 +1,45 @@ +# +# Cookbook Name:: zf2 +# Attribute:: apache2 +# +# Copyright (C) 2014 Triple-networks +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +default['apache']['contact'] = node['application']['admin']['email'] + +default['apache']['default_site_enabled'] = true # false + +default['apache']['default_modules'] = %w[ + status alias auth_basic autoindex + dir env mime negotiation setenvif + mod_deflate mod_expires mod_headers mod_php5 mod_rewrite +] + +# custom +default['apache']['canonical_host'] = false + + + +# default['apache']['listen_addresses'] #- Addresses that httpd should listen on. Default is any ("*"). +# default['apache']['listen_ports'] #- Ports that httpd should listen on. Default is port 80. +# default['apache']['contact'] #- Value for ServerAdmin directive. Default "ops@example.com". +# default['apache']['timeout'] #- Value for the Timeout directive. Default is 300. +# default['apache']['keepalive'] #- Value for the KeepAlive directive. Default is On. +# default['apache']['keepaliverequests'] #- Value for MaxKeepAliveRequests. Default is 100. +# default['apache']['keepalivetimeout'] #- Value for the KeepAliveTimeout directive. Default is 5. +# default['apache']['sysconfig_additional_params'] #- Additionals variables set in sysconfig file. Default is empty. +# default['apache']['default_modules'] #- Array of module names. Can take "mod_FOO" or "FOO" as names, where FOO is the apache module, e.g. "mod_status" or "status". +# The modules listed in default_modules will be included as recipes in recipe[apache::default]. diff --git a/attributes/default.rb b/attributes/default.rb index 3b46f82..d61e4c3 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -19,35 +19,4 @@ # ::Chef::Node.send(:include, Opscode::OpenSSL::Password) -default['application']['admin']['email'] = 'admin@example.com' - - -# apache2 -default['apache']['default_site_enabled'] = true #false - -default['apache']['default_modules'] = %w[ - status alias auth_basic autoindex - dir env mime negotiation setenvif - mod_deflate mod_expires mod_headers mod_php5 mod_rewrite -] - -# default['apache']['listen_addresses'] #- Addresses that httpd should listen on. Default is any ("*"). -# default['apache']['listen_ports'] #- Ports that httpd should listen on. Default is port 80. -# default['apache']['contact'] #- Value for ServerAdmin directive. Default "ops@example.com". -# default['apache']['timeout'] #- Value for the Timeout directive. Default is 300. -# default['apache']['keepalive'] #- Value for the KeepAlive directive. Default is On. -# default['apache']['keepaliverequests'] #- Value for MaxKeepAliveRequests. Default is 100. -# default['apache']['keepalivetimeout'] #- Value for the KeepAliveTimeout directive. Default is 5. -# default['apache']['sysconfig_additional_params'] #- Additionals variables set in sysconfig file. Default is empty. -# default['apache']['default_modules'] #- Array of module names. Can take "mod_FOO" or "FOO" as names, where FOO is the apache module, e.g. "mod_status" or "status". -# The modules listed in default_modules will be included as recipes in recipe[apache::default]. - - -# php -default['php']['set_version'] = '5.4' -default['php']['packages'] = %w( - curl libxml2-utils - php-pear php-apc - phpmyadmin - php5 php5-cli php5-common php5-curl php5-dev php5-gd php5-intl php5-mcrypt php5-mysql php5-xmlrpc php5-xsl -) +default['application']['admin']['email'] = 'admin@zf2.example.com' diff --git a/attributes/php.rb b/attributes/php.rb new file mode 100644 index 0000000..cf7be45 --- /dev/null +++ b/attributes/php.rb @@ -0,0 +1,26 @@ +# +# Cookbook Name:: zf2 +# Attribute:: php +# +# Copyright (C) 2014 Triple-networks +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +default['php']['set_version'] = '5.4' +default['php']['packages'] = %w( + curl libxml2-utils + php-pear php-apc + phpmyadmin + php5 php5-cli php5-common php5-curl php5-dev php5-gd php5-intl php5-mcrypt php5-mysql php5-xmlrpc php5-xsl +) diff --git a/metadata.rb b/metadata.rb index c1b37b7..23ace53 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,12 +4,12 @@ license 'Apache 2.0' description 'Installs/Configures ZF2' long_description 'Installs/Configures ZF2' -version '0.4.4' +version '0.4.5' -depends 'baseserver', '~> 0.7.3' +depends 'baseserver', '~> 0.7.8' depends 'mysql', '~> 5.2.12' -depends 'apache2', '~> 1.10.4' +depends 'apache2', '~> 1.11.0' depends 'php', '~> 1.4.6' depends 'database', '~> 2.2.0' depends 'nodejs', '~> 1.3.0' diff --git a/recipes/apache2.rb b/recipes/apache2.rb index 51a8835..f591a76 100644 --- a/recipes/apache2.rb +++ b/recipes/apache2.rb @@ -8,11 +8,11 @@ # include_recipe 'apache2' -include_recipe 'apache2::mod_deflate' -include_recipe 'apache2::mod_expires' -include_recipe 'apache2::mod_headers' -include_recipe 'apache2::mod_php5' -include_recipe 'apache2::mod_rewrite' +# include_recipe 'apache2::mod_deflate' +# include_recipe 'apache2::mod_expires' +# include_recipe 'apache2::mod_headers' +# include_recipe 'apache2::mod_php5' +# include_recipe 'apache2::mod_rewrite' begin data_bag('virtualhosts').each do |virtualhost| @@ -30,6 +30,8 @@ # set default template hosttemplate = hostdata['template'] hosttemplate ||= 'web_app.conf.erb' + hostcookbook = hostdata['cookbook'] + hostcookbook ||= cookbook_name.to_s #webappname = '000-'+hostdata['id'] @@ -38,7 +40,7 @@ server_name hostdata['server_name'] server_aliases hostdata['server_aliases'] template hosttemplate - # cookbook hostdata['cookbook'] if hostdata['cookbook'] + cookbook hostcookbook docroot hostdata['docroot'] allow_override hostdata['allow_override'] directory_options hostdata['directory_options'] diff --git a/recipes/projects.rb b/recipes/projects.rb index 3caacb1..0650020 100644 --- a/recipes/projects.rb +++ b/recipes/projects.rb @@ -30,6 +30,7 @@ begin Chef::Log.debug(projectdata.inspect) + Chef::Log.debug("Cookbook #{cookbook_name} in the recipe: #{recipe_name}.") parentprojectdir = Pathname.new(projectdata['projectdir']).parent diff --git a/templates/default/web_app.conf.erb b/templates/default/web_app.conf.erb index 03725f3..56e1763 100644 --- a/templates/default/web_app.conf.erb +++ b/templates/default/web_app.conf.erb @@ -34,18 +34,20 @@ ErrorLog <%= node['apache']['log_dir'] %>/<%= @params[:name] %>-error.log CustomLog <%= node['apache']['log_dir'] %>/<%= @params[:name] %>-access.log combined - <% if @params[:directory_index] -%> +<% if @params[:directory_index] -%> DirectoryIndex <%= [@params[:directory_index]].flatten.join " " %> - <% end -%> +<% end -%> RewriteEngine On RewriteLog <%= node['apache']['log_dir'] %>/<%= @application_name %>-rewrite.log RewriteLogLevel 0 +<% if @params[:canonical_host] -%> # Canonical host, <%= @params[:server_name] %> RewriteCond %{HTTP_HOST} !^<%= @params[:server_name] %> [NC] RewriteCond %{HTTP_HOST} !^$ RewriteRule ^/(.*)$ http://<%= @params[:server_name] %>/$1 [L,R=301] +<% end -%> RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f RewriteCond %{SCRIPT_FILENAME} !maintenance.html