mod_php_apache2.rb 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #
  2. # Cookbook Name:: application
  3. # Recipe:: mod_php_apache2
  4. #
  5. # Copyright 2011, Opscode, Inc.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. app = node.run_state[:current_app]
  20. node.default['apache']['listen_ports'] = [ "8080" ]
  21. include_recipe "apache2"
  22. include_recipe "apache2::mod_rewrite"
  23. include_recipe "apache2::mod_deflate"
  24. include_recipe "apache2::mod_headers"
  25. include_recipe "apache2::mod_php5"
  26. server_aliases = [ "#{app['id']}.#{node['domain']}", node['fqdn'] ]
  27. if node.has_key?("cloud")
  28. server_aliases << node['cloud']['public_hostname']
  29. end
  30. web_app app['id'] do
  31. docroot "#{app['deploy_to']}/current"
  32. template 'php.conf.erb'
  33. server_name "#{app['id']}.#{node['domain']}"
  34. server_aliases server_aliases
  35. log_dir node['apache']['log_dir']
  36. end
  37. if ::File.exists?(::File.join(app['deploy_to'], "current"))
  38. d = resources(:deploy_revision => app['id'])
  39. d.restart_command do
  40. service "apache2" do action :restart; end
  41. end
  42. end
  43. apache_site "000-default" do
  44. enable false
  45. end