passenger 5.0.7 → 5.0.8

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of passenger might be problematic. Click here for more details.

Files changed (50) hide show
  1. checksums.yaml +8 -8
  2. checksums.yaml.gz.asc +7 -7
  3. data.tar.gz.asc +7 -7
  4. data/CHANGELOG +17 -0
  5. data/bin/passenger-install-apache2-module +37 -5
  6. data/build/basics.rb +4 -1
  7. data/build/integration_tests.rb +6 -3
  8. data/build/packaging.rb +64 -4
  9. data/dev/ci/run_jenkins.sh +1 -7
  10. data/dev/ci/run_travis.sh +2 -34
  11. data/doc/Users guide Apache.html +184 -96
  12. data/doc/Users guide Apache.idmap.txt +9 -3
  13. data/doc/Users guide Apache.txt +11 -31
  14. data/doc/Users guide Nginx.html +192 -53
  15. data/doc/Users guide Nginx.idmap.txt +9 -3
  16. data/doc/Users guide Nginx.txt +7 -2
  17. data/doc/Users guide Standalone.html +113 -55
  18. data/doc/Users guide Standalone.idmap.txt +5 -1
  19. data/doc/users_guide_snippets/installation.txt +130 -66
  20. data/doc/users_guide_snippets/tips.txt +38 -0
  21. data/ext/apache2/Hooks.cpp +28 -2
  22. data/ext/common/AgentsStarter.h +6 -0
  23. data/ext/common/ApplicationPool2/AppTypes.h +1 -1
  24. data/ext/common/ApplicationPool2/Group.h +25 -3
  25. data/ext/common/ApplicationPool2/Options.h +1 -1
  26. data/ext/common/ApplicationPool2/Pool/GarbageCollection.h +6 -3
  27. data/ext/common/Constants.h +3 -1
  28. data/ext/common/ServerKit/http_parser.cpp +7 -1
  29. data/ext/common/agents/HelperAgent/Main.cpp +53 -0
  30. data/ext/common/agents/HelperAgent/RequestHandler.h +4 -0
  31. data/ext/common/agents/HelperAgent/RequestHandler/ForwardResponse.cpp +6 -0
  32. data/ext/nginx/ngx_http_passenger_module.c +2 -2
  33. data/lib/phusion_passenger.rb +15 -2
  34. data/lib/phusion_passenger/admin_tools/instance_registry.rb +40 -27
  35. data/lib/phusion_passenger/config/install_agent_command.rb +4 -0
  36. data/lib/phusion_passenger/config/install_standalone_runtime_command.rb +6 -0
  37. data/lib/phusion_passenger/config/installation_utils.rb +8 -2
  38. data/lib/phusion_passenger/config/nginx_engine_compiler.rb +16 -7
  39. data/lib/phusion_passenger/config/validate_install_command.rb +87 -11
  40. data/lib/phusion_passenger/constants.rb +2 -0
  41. data/lib/phusion_passenger/platform_info/apache.rb +114 -33
  42. data/lib/phusion_passenger/platform_info/apache_detector.rb +28 -4
  43. data/lib/phusion_passenger/platform_info/compiler.rb +22 -27
  44. data/lib/phusion_passenger/standalone/start_command.rb +16 -3
  45. data/lib/phusion_passenger/standalone/start_command/builtin_engine.rb +1 -0
  46. data/resources/templates/apache2/rpm_installation_recommended.txt.erb +19 -0
  47. data/resources/templates/standalone/config.erb +3 -2
  48. metadata +3 -3
  49. metadata.gz.asc +7 -7
  50. data/dev/ci/run_rpm_tests.sh +0 -80
@@ -84,6 +84,10 @@ module PhusionPassenger
84
84
  options[:download_args] << " "
85
85
  options[:download_args] << "--no-download-progress"
86
86
  end
87
+ opts.on("--auto", "Run in non-interactive mode. Default when#{nl}" +
88
+ "stdin or stdout is not a TTY") do
89
+ options[:compile_args] << "--auto"
90
+ end
87
91
  opts.on("-f", "--force", "Skip sanity checks") do
88
92
  options[:force] = true
89
93
  options[:download_args] << "--force"
@@ -91,6 +91,8 @@ module PhusionPassenger
91
91
  opts.on("--nginx-version VERSION", String, "Nginx version to compile. " +
92
92
  "Default: #{PREFERRED_NGINX_VERSION}") do |val|
93
93
  options[:nginx_version] = val
94
+ options[:compile_args] << "--nginx-version"
95
+ options[:compile_args] << val
94
96
  end
95
97
  opts.on("--nginx-tarball PATH", String, "Use the given Nginx tarball instead of#{nl}" +
96
98
  "downloading it. You MUST also specify the#{nl}" +
@@ -106,6 +108,10 @@ module PhusionPassenger
106
108
  options[:download_args] << " "
107
109
  options[:download_args] << "--no-download-progress"
108
110
  end
111
+ opts.on("--auto", "Run in non-interactive mode. Default when#{nl}" +
112
+ "stdin or stdout is not a TTY") do
113
+ options[:install_agent_args] << "--auto"
114
+ end
109
115
  opts.on("-f", "--force", "Skip sanity checks") do
110
116
  options[:force] = true
111
117
  options[:install_agent_args] << "--force"
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  #
3
3
  # Phusion Passenger - https://www.phusionpassenger.com/
4
- # Copyright (c) 2014 Phusion
4
+ # Copyright (c) 2014-2015 Phusion
5
5
  #
6
6
  # "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
7
7
  #
@@ -233,7 +233,13 @@ module PhusionPassenger
233
233
 
234
234
  def render_template(name, options = {})
235
235
  options.merge!(:colors => @colors || PhusionPassenger::Utils::AnsiColors.new)
236
- puts ConsoleTextTemplate.new({ :file => "config/#{name}" }, options).result
236
+ # This check here is necessary for NginxEngineCompiler. NginxEngineCompiler
237
+ # derives from AbstractInstaller but also includes InstallationUtils. We want
238
+ # the AbstractInstaller methods to work when they call render_template.
239
+ if !File.exist?("#{PhusionPassenger.resources_dir}/templates/#{name}.txt.erb")
240
+ name = "config/#{name}"
241
+ end
242
+ puts ConsoleTextTemplate.new({ :file => name }, options).result
237
243
  end
238
244
  end
239
245
 
@@ -84,7 +84,9 @@ module PhusionPassenger
84
84
  puts "<banner>Installing...</banner>"
85
85
  download_and_extract_nginx_sources
86
86
  determine_support_libraries
87
- compile_support_libraries
87
+ if PhusionPassenger.build_system_dir
88
+ compile_support_libraries
89
+ end
88
90
  configure_and_compile_nginx
89
91
  end
90
92
 
@@ -230,11 +232,18 @@ module PhusionPassenger
230
232
  end
231
233
 
232
234
  def determine_support_libraries
233
- lib_dir = "#{@working_dir}/common/libpassenger_common"
234
- @support_libs = COMMON_LIBRARY.only(*NGINX_LIBS_SELECTOR).
235
- set_output_dir(lib_dir).
236
- link_objects
237
- @support_libs << "#{@working_dir}/common/libboost_oxt.a"
235
+ if PhusionPassenger.build_system_dir
236
+ lib_dir = "#{@working_dir}/common/libpassenger_common"
237
+ @support_libs = COMMON_LIBRARY.only(*NGINX_LIBS_SELECTOR).
238
+ set_output_dir(lib_dir).
239
+ link_objects
240
+ @support_libs << "#{@working_dir}/common/libboost_oxt.a"
241
+ else
242
+ @support_libs = COMMON_LIBRARY.only(*NGINX_LIBS_SELECTOR).
243
+ set_output_dir("#{PhusionPassenger.lib_dir}/common/libpassenger_common").
244
+ link_objects
245
+ @support_libs << "#{PhusionPassenger.lib_dir}/common/libboost_oxt.a"
246
+ end
238
247
  @support_libs_string = @support_libs.join(" ")
239
248
  end
240
249
 
@@ -295,7 +304,7 @@ module PhusionPassenger
295
304
  command << "#{shell} ./configure --prefix=/tmp " +
296
305
  "#{STANDALONE_NGINX_CONFIGURE_OPTIONS} " +
297
306
  "--add-module=#{Shellwords.escape PhusionPassenger.nginx_module_source_dir}"
298
- run_command_yield_activity(command) do |throbber|
307
+ run_command_yield_activity(command) do
299
308
  yield
300
309
  end
301
310
  end
@@ -42,14 +42,14 @@ module PhusionPassenger
42
42
  parse_options
43
43
  prepare
44
44
  begin
45
- if !@options[:auto]
45
+ if !@options[:auto] && !@options[:invoked_from_installer]
46
46
  ask_what_to_validate
47
- if @options[:validate_apache2]
48
- initialize_apache_envvars
47
+ end
48
+ if @options[:validate_apache2]
49
+ initialize_apache_envvars
50
+ if !@options[:auto] && !@options[:invoked_from_installer]
49
51
  check_whether_there_are_multiple_apache_installs
50
52
  end
51
- elsif @options[:validate_apache2]
52
- initialize_apache_envvars
53
53
  end
54
54
 
55
55
  if @options[:validate_passenger]
@@ -57,7 +57,9 @@ module PhusionPassenger
57
57
  check_no_other_installs_in_path
58
58
  end
59
59
  if @options[:validate_apache2]
60
- check_apache2_load_module_config
60
+ if check_apache2_installed
61
+ check_apache2_load_module_config
62
+ end
61
63
  end
62
64
 
63
65
  if @options[:summary]
@@ -147,6 +149,7 @@ module PhusionPassenger
147
149
  PhusionPassenger.require_passenger_lib 'platform_info/ruby'
148
150
  PhusionPassenger.require_passenger_lib 'platform_info/apache'
149
151
  PhusionPassenger.require_passenger_lib 'platform_info/apache_detector'
152
+ PhusionPassenger.require_passenger_lib 'platform_info/depcheck'
150
153
  require 'stringio'
151
154
  require 'pathname'
152
155
 
@@ -239,9 +242,16 @@ module PhusionPassenger
239
242
  # These may not be in PATH if the user did not run this command through sudo.
240
243
  paths << "/usr/bin"
241
244
  paths << "/usr/sbin"
242
- paths.delete(gem_bindir)
243
- paths.delete(homebrew_bindir)
244
- paths.delete(PhusionPassenger.bin_dir)
245
+ # Some of the paths may be symlinks, so we take the realpaths when
246
+ # possible and remove duplicates. This is especially important on
247
+ # Red Hat 7, where /bin is a symlink to /usr/bin.
248
+ paths.map! do |path|
249
+ try_realpath(path)
250
+ end
251
+
252
+ paths.delete(try_realpath(gem_bindir))
253
+ paths.delete(try_realpath(homebrew_bindir))
254
+ paths.delete(try_realpath(PhusionPassenger.bin_dir))
245
255
  paths.uniq!
246
256
 
247
257
  other_installs = []
@@ -272,6 +282,11 @@ module PhusionPassenger
272
282
  end
273
283
 
274
284
  def check_whether_there_are_multiple_apache_installs
285
+ if PlatformInfo.httpd.nil? || PlatformInfo.apxs2.nil?
286
+ # check_apache2_installed will handle this.
287
+ return
288
+ end
289
+
275
290
  log '<banner>Checking whether there are multiple Apache installations...</banner>'
276
291
 
277
292
  output = StringIO.new
@@ -358,6 +373,55 @@ module PhusionPassenger
358
373
  end
359
374
  end
360
375
 
376
+ def check_apache2_installed
377
+ checking "whether Apache is installed"
378
+
379
+ if PlatformInfo.httpd
380
+ if PlatformInfo.apxs2
381
+ check_ok
382
+ true
383
+ else
384
+ check_error
385
+
386
+ PlatformInfo::Depcheck.load("depcheck_specs/apache2")
387
+ dep = PlatformInfo::Depcheck.find("apache2-dev")
388
+ install_instructions = dep.install_instructions.split("\n").join("\n ")
389
+
390
+ if !@options[:invoked_from_installer]
391
+ next_step = "When done, please re-run this program."
392
+ end
393
+
394
+ suggest %Q{
395
+ Unable to validate your Apache installation: more software required
396
+
397
+ This program requires the <b>apxs2</b> tool in order to be able to validate your
398
+ Apache installation. This tool is currently not installed. You can solve this
399
+ as follows:
400
+
401
+ #{install_instructions}
402
+
403
+ #{next_step}
404
+ }
405
+
406
+ false
407
+ end
408
+ else
409
+ check_error
410
+
411
+ PlatformInfo::Depcheck.load("depcheck_specs/apache2")
412
+ dep = PlatformInfo::Depcheck.find("apache2")
413
+ install_instructions = dep.install_instructions.split("\n").join("\n ")
414
+
415
+ suggest %Q{
416
+ Apache is not installed. You can solve this as follows:
417
+
418
+ #{install_instructions}
419
+ }
420
+
421
+ false
422
+ end
423
+ end
424
+
361
425
  def check_apache2_load_module_config
362
426
  checking "whether the Passenger module is correctly configured in Apache"
363
427
 
@@ -455,8 +519,8 @@ module PhusionPassenger
455
519
  module_path = "#{PlatformInfo.httpd_default_root}/#{module_path}"
456
520
  end
457
521
  # Resolve symlinks.
458
- module_path = Pathname.new(module_path).realpath
459
- expected_module_path = Pathname.new(PhusionPassenger.apache2_module_path).realpath
522
+ module_path = try_realpath(module_path)
523
+ expected_module_path = try_realpath(PhusionPassenger.apache2_module_path)
460
524
 
461
525
  if module_path == expected_module_path
462
526
  check_ok
@@ -653,6 +717,18 @@ module PhusionPassenger
653
717
  def ruby_command
654
718
  PlatformInfo.ruby_command
655
719
  end
720
+
721
+ def try_realpath(path)
722
+ if path
723
+ begin
724
+ Pathname.new(path).realpath.to_s
725
+ rescue Errno::ENOENT, Errno::EACCES
726
+ path
727
+ end
728
+ else
729
+ nil
730
+ end
731
+ end
656
732
  end
657
733
 
658
734
  end # module Config
@@ -53,6 +53,8 @@ module PhusionPassenger
53
53
  DEFAULT_WEB_APP_USER = "nobody"
54
54
  DEFAULT_APP_ENV = "production"
55
55
  DEFAULT_SPAWN_METHOD = "smart"
56
+ # Apache's unixd.h also defines DEFAULT_USER, so we avoid naming clash here.
57
+ PASSENGER_DEFAULT_USER = "nobody"
56
58
  DEFAULT_CONCURRENCY_MODEL = "process"
57
59
  DEFAULT_STICKY_SESSIONS_COOKIE_NAME = "_passenger_route"
58
60
  DEFAULT_APP_THREAD_COUNT = 1
@@ -112,10 +112,26 @@ module PhusionPassenger
112
112
  else
113
113
  apache2ctl = self.apache2ctl
114
114
  end
115
- if apache2ctl
115
+ if os_name == "linux" &&
116
+ linux_distro_tags.include?(:gentoo) &&
117
+ apache2ctl == "/usr/sbin/apache2ctl"
118
+ # On Gentoo, `apache2ctl -V` doesn't forward the command to `apache2 -V`,
119
+ # but instead prints the OpenRC init system's version.
120
+ # https://github.com/phusion/passenger/issues/1510
121
+ if options
122
+ httpd = options[:httpd] || self.httpd(options)
123
+ else
124
+ httpd = self.httpd
125
+ end
126
+ version_command = httpd
127
+ else
128
+ version_command = apache2ctl
129
+ end
130
+
131
+ if version_command
116
132
  create_temp_file("apache2ctl_V") do |filename, f|
117
133
  e_filename = Shellwords.escape(filename)
118
- output = `#{apache2ctl} -V 2>#{e_filename}`
134
+ output = `#{version_command} -V 2>#{e_filename}`
119
135
 
120
136
  stderr_text = File.open(filename, "rb") do |f2|
121
137
  f2.read
@@ -545,22 +561,31 @@ module PhusionPassenger
545
561
  flags << "-fPIC"
546
562
  end
547
563
  if with_apr_flags
548
- flags << apr_flags
549
- flags << apu_flags
564
+ if language == :c
565
+ flags << apr_cflags
566
+ flags << apu_cflags
567
+ else
568
+ flags << apr_cxxflags
569
+ flags << apu_cxxflags
570
+ end
550
571
  end
551
572
  if !apxs2.nil?
552
573
  apxs2_flags = `#{apxs2} -q CFLAGS`.strip << " -I" << `#{apxs2} -q INCLUDEDIR`.strip
553
574
  apxs2_flags.gsub!(/-O\d? /, '')
554
575
 
555
- # Remove flags not supported by GCC
556
- if os_name =~ /solaris/ # TODO: Add support for people using SunStudio
557
- # The big problem is Coolstack apxs includes a bunch of solaris -x directives.
558
- options = apxs2_flags.split
559
- options.reject! { |f| f =~ /^\-x/ }
560
- options.reject! { |f| f =~ /^\-Xa/ }
561
- options.reject! { |f| f =~ /^\-fast/ }
562
- options.reject! { |f| f =~ /^\-mt/ }
563
- apxs2_flags = options.join(' ')
576
+ if os_name =~ /solaris/
577
+ if (language == :c && !cc_is_sun_studio?) || (language == :cxx && !cxx_is_sun_studio?)
578
+ # Remove flags not supported by GCC
579
+ # The big problem is Coolstack apxs includes a bunch of solaris -x directives.
580
+ options = apxs2_flags.split
581
+ options.reject! { |f| f =~ /^\-x/ }
582
+ options.reject! { |f| f =~ /^\-Xa/ }
583
+ options.reject! { |f| f =~ /^\-fast/ }
584
+ options.reject! { |f| f =~ /^\-mt/ }
585
+ options.reject! { |f| f =~ /^\-W2/ }
586
+ apxs2_flags = options.join(' ')
587
+ apxs2_flags.gsub!(/ ?-Qoption cg ?/, " ")
588
+ end
564
589
  end
565
590
 
566
591
  if os_name == "linux" &&
@@ -629,30 +654,50 @@ module PhusionPassenger
629
654
  else
630
655
  flags = "-fPIC"
631
656
  end
632
- flags << " #{apr_libs} #{apu_libs}"
657
+ flags << " #{apr_cxx_ldflags} #{apu_cxx_ldflags}"
633
658
  flags.strip!
634
659
  return flags
635
660
  end
636
661
  memoize :apache2_module_cxx_ldflags
637
662
 
638
663
  # The C compiler flags that are necessary for programs that use APR.
639
- def self.apr_flags
640
- return determine_apr_info[0]
664
+ def self.apr_cflags
665
+ determine_apr_c_info[0]
666
+ end
667
+
668
+ # The C++ compiler flags that are necessary for programs that use APR.
669
+ def self.apr_cxxflags
670
+ determine_apr_c_info[0]
641
671
  end
642
672
 
643
673
  # The linker flags that are necessary for linking programs that use APR.
644
- def self.apr_libs
645
- return determine_apr_info[1]
674
+ def self.apr_c_ldflags
675
+ determine_apr_c_info[1]
676
+ end
677
+
678
+ # The linker flags that are necessary for linking C++ programs that use APR.
679
+ def self.apr_cxx_ldflags
680
+ determine_apr_cxx_info[1]
646
681
  end
647
682
 
648
683
  # The C compiler flags that are necessary for programs that use APR-Util.
649
- def self.apu_flags
650
- return determine_apu_info[0]
684
+ def self.apu_cflags
685
+ determine_apu_c_info[0]
686
+ end
687
+
688
+ # The C++ compiler flags that are necessary for programs that use APR-Util.
689
+ def self.apu_cxxflags
690
+ determine_apu_cxx_info[0]
651
691
  end
652
692
 
653
- # The linker flags that are necessary for linking programs that use APR-Util.
654
- def self.apu_libs
655
- return determine_apu_info[1]
693
+ # The linker flags that are necessary for linking C programs that use APR-Util.
694
+ def self.apu_c_ldflags
695
+ determine_apu_c_info[1]
696
+ end
697
+
698
+ # The linker flags that are necessary for linking C++ programs that use APR-Util.
699
+ def self.apu_cxx_ldflags
700
+ determine_apu_cxx_info[1]
656
701
  end
657
702
 
658
703
  ################ Miscellaneous information ################
@@ -670,38 +715,74 @@ module PhusionPassenger
670
715
  memoize :apr_config_needed_for_building_apache_modules?, true
671
716
 
672
717
  private
673
- def self.determine_apr_info
718
+ def self.determine_apr_info(language)
674
719
  if apr_config.nil?
675
- return [nil, nil]
720
+ [nil, nil]
676
721
  else
677
722
  flags = `#{apr_config} --cppflags --includes`.strip
678
723
  libs = `#{apr_config} --link-ld`.strip
679
724
  flags.gsub!(/-O\d? /, '')
680
725
  if os_name =~ /solaris/
681
- # Remove flags not supported by GCC
682
- flags = flags.split(/ +/).reject{ |f| f =~ /^\-mt/ }.join(' ')
726
+ if (language == :c && !cc_is_sun_studio?) || (language == :cxx && !cxx_is_sun_studio?)
727
+ # Remove flags not supported by non-Sun Studio compilers
728
+ flags = flags.split(/ +/).reject do |f|
729
+ f =~ /^\-mt/
730
+ end
731
+ flags = flags.join(' ')
732
+ end
683
733
  elsif os_name =~ /aix/
684
734
  libs << " -Wl,-G -Wl,-brtl"
685
735
  end
686
- return [flags, libs]
736
+ [flags, libs]
687
737
  end
688
738
  end
689
- memoize :determine_apr_info, true
690
739
  private_class_method :determine_apr_info
691
740
 
692
- def self.determine_apu_info
741
+ def self.determine_apr_c_info
742
+ determine_apr_info(:c)
743
+ end
744
+ private_class_method :determine_apr_c_info
745
+ memoize :determine_apr_c_info, true
746
+
747
+ def self.determine_apr_cxx_info
748
+ determine_apr_info(:cxx)
749
+ end
750
+ private_class_method :determine_apr_cxx_info
751
+ memoize :determine_apr_cxx_info, true
752
+
753
+ def self.determine_apu_info(language)
693
754
  if apu_config.nil?
694
- return [nil, nil]
755
+ [nil, nil]
695
756
  else
696
757
  flags = `#{apu_config} --includes`.strip
697
758
  libs = `#{apu_config} --link-ld`.strip
698
759
  flags.gsub!(/-O\d? /, '')
699
- return [flags, libs]
760
+ if os_name =~ /solaris/
761
+ if (language == :c && !cc_is_sun_studio?) || (language == :cxx && !cxx_is_sun_studio?)
762
+ # Remove flags not supported by non-Sun Studio compilers
763
+ flags = flags.split(/ +/).reject do |f|
764
+ f =~ /^\-mt/
765
+ end
766
+ flags = flags.join(' ')
767
+ end
768
+ end
769
+ [flags, libs]
700
770
  end
701
771
  end
702
- memoize :determine_apu_info, true
703
772
  private_class_method :determine_apu_info
704
773
 
774
+ def self.determine_apu_c_info
775
+ determine_apu_info(:c)
776
+ end
777
+ private_class_method :determine_apu_c_info
778
+ memoize :determine_apu_c_info, true
779
+
780
+ def self.determine_apu_cxx_info
781
+ determine_apu_info(:cxx)
782
+ end
783
+ private_class_method :determine_apu_cxx_info
784
+ memoize :determine_apu_cxx_info, true
785
+
705
786
  def self.scan_for_included_apache2_config_files(config_file, state, options = nil)
706
787
  begin
707
788
  config = File.open(config_file, "rb") do |f|