apache.php

Classes

File

http/Provision/Service/http/apache.php
View source
  1. <?php
  2. class Provision_Service_http_apache extends Provision_Service_http_public {
  3. protected $application_name = 'apache';
  4. protected $has_restart_cmd = TRUE;
  5. function default_restart_cmd() {
  6. return Provision_Service_http_apache::apache_restart_cmd();
  7. }
  8. function cloaked_db_creds() {
  9. return TRUE;
  10. }
  11. function init_server() {
  12. parent::init_server();
  13. $this->configs['server'][] = 'Provision_Config_Apache_Server';
  14. $this->configs['platform'][] = 'Provision_Config_Apache_Platform';
  15. $this->configs['site'][] = 'Provision_Config_Apache_Site';
  16. if (provision_hosting_feature_enabled('subdirs')) {
  17. $this->configs['site'][] = 'Provision_Config_Apache_Subdir';
  18. $this->configs['site'][] = 'Provision_Config_Apache_SubdirVhost';
  19. }
  20. }
  21. /**
  22. * Guess at the likely value of the http_restart_cmd.
  23. *
  24. * This method is a static so that it can be re-used by the apache_ssl
  25. * service, even though it does not inherit this class.
  26. */
  27. public static function apache_restart_cmd() {
  28. $command = '/usr/sbin/apachectl'; // A proper default for most of the world
  29. foreach (explode(':', $_SERVER['PATH']) as $path) {
  30. $options[] = "$path/apache2ctl";
  31. $options[] = "$path/apachectl";
  32. }
  33. // Try to detect the apache restart command.
  34. $options[] = '/usr/local/sbin/apachectl'; // freebsd
  35. $options[] = '/usr/sbin/apache2ctl'; // debian + apache2
  36. $options[] = '/usr/apache2/2.2/bin'; // Solaris
  37. $options[] = $command;
  38. foreach ($options as $test) {
  39. if (is_executable($test)) {
  40. $command = $test;
  41. break;
  42. }
  43. }
  44. return "sudo $command graceful";
  45. }
  46. /**
  47. * Restart apache to pick up the new config files.
  48. */
  49. function parse_configs() {
  50. return $this->restart();
  51. }
  52. }