Class: PhusionPassenger::PlatformInfo::ApacheDetector
- Defined in:
- lib/phusion_passenger/platform_info/apache_detector.rb
Overview
Detects all possible Apache installations on the system, and presents the autodetection information to the user in a friendly way. It turns out too many people have multiple Apache installations on their system, but they don’t know about that, or they don’t know how to compile against the correct Apache installation. This tool helps them.
Defined Under Namespace
Classes: Result
Instance Attribute Summary collapse
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #detect_all ⇒ Object
- #detect_one(apxs2) ⇒ Object
- #finish ⇒ Object
-
#initialize(output) ⇒ ApacheDetector
constructor
A new instance of ApacheDetector.
- #report ⇒ Object
- #result_for(apxs2) ⇒ Object
Constructor Details
#initialize(output) ⇒ ApacheDetector
Returns a new instance of ApacheDetector.
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/phusion_passenger/platform_info/apache_detector.rb', line 83 def initialize(output) @output = output @results = [] PlatformInfo.verbose = true PlatformInfo.log_implementation = lambda do || if =~ /: found$/ log("<green> * #{}</green>") else log(" * #{}") end end end |
Instance Attribute Details
#results ⇒ Object (readonly)
Returns the value of attribute results.
81 82 83 |
# File 'lib/phusion_passenger/platform_info/apache_detector.rb', line 81 def results @results end |
Instance Method Details
#detect_all ⇒ Object
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/phusion_passenger/platform_info/apache_detector.rb', line 101 def detect_all log "<banner>Looking for possible Apache installations...</banner>" apxses = PlatformInfo.find_all_commands("apxs2") + PlatformInfo.find_all_commands("apxs") apxses = remove_symlink_duplications(apxses) log "" apxses.each do |apxs2| detect_one(apxs2) end end |
#detect_one(apxs2) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/phusion_passenger/platform_info/apache_detector.rb', line 112 def detect_one(apxs2) log "<banner>Analyzing #{apxs2}...</banner>" add_result do |result| result.apxs2 = apxs2 log "Detecting main Apache executable..." result.httpd = PlatformInfo.httpd(:apxs2 => apxs2) if result.httpd if result.version = PlatformInfo.httpd_version(:httpd => result.httpd) log "Version detected: #{result.version}" else log "<red>Cannot detect version!</red>" result.httpd = nil end end if result.httpd log "Detecting control command..." result.ctl = PlatformInfo.apache2ctl(:apxs2 => apxs2) result.httpd = nil if !result.ctl end if result.httpd result.config_file = PlatformInfo.httpd_default_config_file(:httpd => result.httpd) if result.config_file log "Default config file location detected: #{result.config_file}" else log "<red>Cannot detect default config file location!</red>" result.httpd = nil end end if result.httpd result.error_log = PlatformInfo.httpd_actual_error_log(:httpd => result.httpd) if result.error_log log "Error log file detected: #{result.error_log}" else log "<red>Cannot detect error log file!</red>" result.httpd = nil end end if result.httpd if PlatformInfo.httpd_supports_a2enmod?(:httpd => result.httpd) log "This Apache installation does not support a2enmod." else log "Detecting a2enmod and a2dismod..." result.a2enmod = PlatformInfo.a2enmod(:apxs2 => apxs2) result.a2dismod = PlatformInfo.a2dismod(:apxs2 => apxs2) end end if result.httpd log "<green>Found a usable Apache installation using #{apxs2}.</green>" true else log "<yellow>Cannot find a usable Apache installation using #{apxs2}.</yellow>" false end end log "" end |
#finish ⇒ Object
96 97 98 99 |
# File 'lib/phusion_passenger/platform_info/apache_detector.rb', line 96 def finish PlatformInfo.verbose = false PlatformInfo.log_implementation = nil end |
#report ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/phusion_passenger/platform_info/apache_detector.rb', line 169 def report log "<banner>Final autodetection results</banner>" @results.each do |result| result.report end if @results.empty? log "<red>Sorry, this program cannot find an Apache installation.</red>" log "" log "To install Apache, please run the following. It will tell you how to install Apache." log "" log " <b>#{PhusionPassenger.bin_dir}/passenger-install-apache2-module</b>" log "" log "If you are sure that you have Apache installed, please read the documentation:" log " * <b>#{PhusionPassenger.apache2_doc_path}</b>, section" log " section 'Installation' -> 'Customizing the compilation process' ->" log " 'Forcing location of command line tools and dependencies'" log " * Or visit the online version:" log " <b>#{APACHE2_DOC_URL}#_forcing_location_of_command_line_tools_and_dependencies</b>" elsif @results.size > 1 log "<yellow>WARNING: You have multiple Apache installations on your system!</yellow>" log "You are strongly recommended to read this section of the documentation:" log " * <b>#{PhusionPassenger.apache2_doc_path}</b>, section" log " section 'Installation' -> 'Customizing the compilation process' ->" log " 'Forcing location of command line tools and dependencies'" log " * Or visit the online version:" log " <b>#{APACHE2_DOC_URL}#_forcing_location_of_command_line_tools_and_dependencies</b>" end end |
#result_for(apxs2) ⇒ Object
198 199 200 201 202 |
# File 'lib/phusion_passenger/platform_info/apache_detector.rb', line 198 def result_for(apxs2) # All the results use realpaths, so the input must too. apxs2 = Pathname.new(apxs2).realpath return @results.find { |r| r.apxs2 == apxs2 } end |