forked from poise/application_php
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Andrea Campi
committed
Apr 3, 2012
1 parent
015a6a5
commit 5c806b7
Showing
3 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# | ||
# Cookbook Name:: application_php | ||
# Provider:: mod_php_apache2 | ||
# | ||
# Copyright 2012, ZephirWorks | ||
# | ||
# 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. | ||
# | ||
|
||
include Chef::Mixin::LanguageIncludeRecipe | ||
|
||
action :before_compile do | ||
|
||
include_recipe "apache2" | ||
include_recipe "apache2::mod_rewrite" | ||
include_recipe "apache2::mod_deflate" | ||
include_recipe "apache2::mod_headers" | ||
include_recipe "apache2::mod_php5" | ||
|
||
unless new_resource.server_aliases | ||
server_aliases = [ "#{new_resource.name}.#{node['domain']}", node['fqdn'] ] | ||
if node.has_key?("cloud") | ||
server_aliases << node['cloud']['public_hostname'] | ||
end | ||
new_resource.server_aliases server_aliases | ||
end | ||
|
||
unless new_resource.restart_command | ||
new_resource.restart_command do | ||
run_context.resource_collection.find(:service => "apache2").run_action(:restart) | ||
end | ||
end | ||
|
||
end | ||
|
||
action :before_deploy do | ||
|
||
new_resource = @new_resource | ||
|
||
web_app new_resource.application.name do | ||
docroot "#{new_resource.application.path}/current" | ||
template new_resource.webapp_template || 'php.conf.erb' | ||
cookbook new_resource.webapp_template ? new_resource.cookbook_name : "application_php" | ||
server_name "#{new_resource.application.name}.#{node['domain']}" | ||
server_aliases new_resource.server_aliases | ||
log_dir node['apache']['log_dir'] | ||
end | ||
|
||
apache_site "000-default" do | ||
enable false | ||
end | ||
|
||
end | ||
|
||
action :before_migrate do | ||
end | ||
|
||
action :before_symlink do | ||
end | ||
|
||
action :before_restart do | ||
end | ||
|
||
action :after_restart do | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# Cookbook Name:: application_php | ||
# Resource:: mod_php_apache2 | ||
# | ||
# Copyright 2012, ZephirWorks | ||
# | ||
# 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. | ||
# | ||
|
||
include Chef::Resource::ApplicationBase | ||
|
||
attribute :server_aliases, :kind_of => [Array, NilClass], :default => nil | ||
# Actually defaults to "php.conf.erb", but nil means it wasn't set by the user | ||
attribute :webapp_template, :kind_of => [String, NilClass], :default => nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<VirtualHost *:8080> | ||
ServerName <%= @params[:server_name] %> | ||
ServerAlias <% @params[:server_aliases].each do |a| %><%= "#{a}" %> <% end %> | ||
DocumentRoot <%= @params[:docroot] %> | ||
RewriteEngine On | ||
|
||
<Directory <%= @params[:docroot] %>> | ||
Options FollowSymLinks | ||
AllowOverride None | ||
Order allow,deny | ||
Allow from all | ||
</Directory> | ||
|
||
<Directory /> | ||
Options FollowSymLinks | ||
AllowOverride None | ||
</Directory> | ||
|
||
<Location /server-status> | ||
SetHandler server-status | ||
|
||
Order Deny,Allow | ||
Deny from all | ||
Allow from 127.0.0.1 | ||
</Location> | ||
|
||
LogLevel info | ||
ErrorLog <%= node[:apache][:log_dir] %>/<%= @params[:name] %>-error.log | ||
CustomLog <%= node[:apache][:log_dir] %>/<%= @params[:name] %>-access.log combined | ||
|
||
RewriteEngine On | ||
RewriteLog <%= node[:apache][:log_dir] %>/<%= @application_name %>-rewrite.log | ||
RewriteLogLevel 0 | ||
</VirtualHost> |