Skip to content
This repository has been archived by the owner on Sep 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #20 from Rud5G/add-canonical
Browse files Browse the repository at this point in the history
Split apache2 attributes, update metadata, recipes
  • Loading branch information
Rud5G committed Aug 16, 2014
2 parents f53d761 8112e5f commit 2e0e0ea
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 43 deletions.
45 changes: 45 additions & 0 deletions attributes/apache2.rb
Original file line number Diff line number Diff line change
@@ -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 "[email protected]".
# 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].
33 changes: 1 addition & 32 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 19,4 @@

# ::Chef::Node.send(:include, Opscode::OpenSSL::Password)

default['application']['admin']['email'] = '[email protected]'


# 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 "[email protected]".
# 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'] = '[email protected]'
26 changes: 26 additions & 0 deletions attributes/php.rb
Original file line number Diff line number Diff line change
@@ -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
)
6 changes: 3 additions & 3 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
14 changes: 8 additions & 6 deletions recipes/apache2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand All @@ -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']

Expand All @@ -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']
Expand Down
1 change: 1 addition & 0 deletions recipes/projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions templates/default/web_app.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2e0e0ea

Please sign in to comment.