passenger 4.0.5 → 4.0.6

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 (162) hide show
  1. data.tar.gz.asc +7 -7
  2. data/.travis.yml +1 -2
  3. data/CONTRIBUTING.md +20 -5
  4. data/CONTRIBUTORS +67 -0
  5. data/LICENSE +1 -1
  6. data/NEWS +48 -0
  7. data/Rakefile +2 -2
  8. data/bin/passenger-config +18 -0
  9. data/bin/passenger-install-apache2-module +2 -0
  10. data/bin/passenger-install-nginx-module +11 -12
  11. data/bin/passenger-memory-stats +2 -0
  12. data/bin/passenger-status +152 -69
  13. data/build/agents.rb +1 -5
  14. data/build/basics.rb +26 -13
  15. data/build/cplusplus_support.rb +9 -0
  16. data/build/debian.rb +129 -0
  17. data/build/documentation.rb +6 -2
  18. data/build/integration_tests.rb +13 -2
  19. data/build/misc.rb +16 -0
  20. data/build/packaging.rb +67 -51
  21. data/build/preprocessor.rb +314 -0
  22. data/build/test_basics.rb +1 -0
  23. data/{debian → debian.template}/README.Debian +0 -0
  24. data/{debian → debian.template}/changelog +131 -0
  25. data/debian.template/compat +1 -0
  26. data/debian.template/control +71 -0
  27. data/debian.template/copyright +385 -0
  28. data/debian.template/libapache2-mod-passenger.install +3 -0
  29. data/{debian → debian.template}/libapache2-mod-passenger.postinst +0 -0
  30. data/{debian → debian.template}/libapache2-mod-passenger.prerm +0 -0
  31. data/debian.template/locations.ini +12 -0
  32. data/debian.template/passenger.conf +4 -0
  33. data/{debian → debian.template}/passenger.load +0 -0
  34. data/debian.template/patches/series +0 -0
  35. data/debian.template/repack.sh +42 -0
  36. data/debian.template/ruby-passenger-dev.install +3 -0
  37. data/debian.template/ruby-passenger-doc.install +2 -0
  38. data/debian.template/ruby-passenger.docs +4 -0
  39. data/debian.template/ruby-passenger.install +11 -0
  40. data/debian.template/ruby-passenger.manpages +4 -0
  41. data/debian.template/rules.template +35 -0
  42. data/debian.template/source/format +1 -0
  43. data/debian.template/watch +3 -0
  44. data/dev/run_travis.sh +46 -46
  45. data/doc/Architectural overview.html +2 -2
  46. data/doc/Packaging.html +27 -18
  47. data/doc/Packaging.txt.md +27 -18
  48. data/doc/Security of user switching support.html +2 -2
  49. data/doc/Users guide Apache.html +881 -95
  50. data/doc/Users guide Apache.idmap.txt +48 -6
  51. data/doc/Users guide Apache.txt +13 -1
  52. data/doc/Users guide Nginx.html +1063 -190
  53. data/doc/Users guide Nginx.idmap.txt +89 -45
  54. data/doc/Users guide Nginx.txt +45 -0
  55. data/doc/Users guide Standalone.html +7 -7
  56. data/doc/users_guide_snippets/alternative_for_flying_passenger.txt +1 -0
  57. data/doc/users_guide_snippets/environment_variables.txt +221 -0
  58. data/doc/users_guide_snippets/installation.txt +66 -17
  59. data/doc/users_guide_snippets/support_information.txt +3 -3
  60. data/doc/users_guide_snippets/tips.txt +352 -40
  61. data/ext/common/Account.h +4 -3
  62. data/ext/common/AccountsDatabase.h +6 -6
  63. data/ext/common/AgentsStarter.h +1 -13
  64. data/ext/common/ApplicationPool2/DirectSpawner.h +4 -4
  65. data/ext/common/ApplicationPool2/DummySpawner.h +1 -1
  66. data/ext/common/ApplicationPool2/Group.h +9 -4
  67. data/ext/common/ApplicationPool2/Implementation.cpp +6 -1
  68. data/ext/common/ApplicationPool2/Options.h +65 -37
  69. data/ext/common/ApplicationPool2/Pool.h +91 -41
  70. data/ext/common/ApplicationPool2/Process.h +6 -6
  71. data/ext/common/ApplicationPool2/SmartSpawner.h +14 -14
  72. data/ext/common/ApplicationPool2/Socket.h +1 -1
  73. data/ext/common/ApplicationPool2/Spawner.h +24 -16
  74. data/ext/common/ApplicationPool2/SpawnerFactory.h +9 -1
  75. data/ext/common/ApplicationPool2/SuperGroup.h +1 -1
  76. data/ext/common/Constants.h +1 -1
  77. data/ext/common/Logging.cpp +12 -7
  78. data/ext/common/MessageServer.h +7 -12
  79. data/ext/common/MultiLibeio.cpp +5 -5
  80. data/ext/common/ResourceLocator.h +2 -6
  81. data/ext/common/ServerInstanceDir.h +37 -10
  82. data/ext/common/UnionStation.h +10 -10
  83. data/ext/common/Utils.cpp +30 -4
  84. data/ext/common/Utils.h +7 -0
  85. data/ext/common/Utils/BlockingQueue.h +2 -2
  86. data/ext/common/Utils/Lock.h +2 -2
  87. data/ext/common/Utils/MessagePassing.h +2 -2
  88. data/ext/common/Utils/Timer.h +4 -4
  89. data/ext/common/agents/HelperAgent/AgentOptions.h +2 -0
  90. data/ext/common/agents/HelperAgent/Main.cpp +57 -16
  91. data/ext/common/agents/HelperAgent/RequestHandler.h +4 -1
  92. data/ext/common/agents/LoggingAgent/AdminController.h +91 -0
  93. data/ext/common/agents/LoggingAgent/LoggingServer.h +46 -29
  94. data/ext/common/agents/LoggingAgent/Main.cpp +43 -16
  95. data/ext/common/agents/LoggingAgent/RemoteSender.h +7 -7
  96. data/ext/common/agents/Watchdog/AgentWatcher.cpp +11 -11
  97. data/ext/common/agents/Watchdog/LoggingAgentWatcher.cpp +3 -1
  98. data/ext/common/agents/Watchdog/Main.cpp +62 -0
  99. data/ext/libeio/config.guess +206 -167
  100. data/ext/libeio/config.sub +142 -68
  101. data/ext/libev/config.guess +304 -290
  102. data/ext/libev/config.sub +198 -77
  103. data/ext/nginx/config +4 -0
  104. data/ext/nginx/ngx_http_passenger_module.c +1 -0
  105. data/ext/oxt/implementation.cpp +4 -4
  106. data/lib/phusion_passenger.rb +14 -5
  107. data/lib/phusion_passenger/abstract_installer.rb +41 -0
  108. data/lib/phusion_passenger/admin_tools/server_instance.rb +48 -39
  109. data/lib/phusion_passenger/message_client.rb +31 -7
  110. data/lib/phusion_passenger/native_support.rb +35 -12
  111. data/lib/phusion_passenger/packaging.rb +16 -2
  112. data/lib/phusion_passenger/platform_info/binary_compatibility.rb +6 -31
  113. data/lib/phusion_passenger/platform_info/operating_system.rb +1 -1
  114. data/lib/phusion_passenger/preloader_shared_helpers.rb +3 -1
  115. data/lib/phusion_passenger/request_handler.rb +1 -1
  116. data/lib/phusion_passenger/standalone/command.rb +6 -6
  117. data/lib/phusion_passenger/standalone/main.rb +23 -8
  118. data/lib/phusion_passenger/standalone/package_runtime_command.rb +9 -5
  119. data/lib/phusion_passenger/standalone/runtime_installer.rb +9 -10
  120. data/lib/phusion_passenger/standalone/start_command.rb +20 -4
  121. data/resources/templates/installer_common/freebsd9_broken_cxx_runtime.txt.erb +19 -0
  122. data/resources/templates/installer_common/low_amount_of_memory_warning.txt.erb +22 -0
  123. data/resources/templates/standalone/config.erb +3 -2
  124. data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +4 -4
  125. data/test/cxx/ApplicationPool2/PoolTest.cpp +1 -1
  126. data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +7 -7
  127. data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +9 -9
  128. data/test/cxx/EventedBufferedInputTest.cpp +17 -17
  129. data/test/cxx/RequestHandlerTest.cpp +5 -5
  130. data/test/cxx/ServerInstanceDirTest.cpp +3 -1
  131. data/test/cxx/TestSupport.h +4 -4
  132. data/test/cxx/UnionStationTest.cpp +3 -1
  133. data/test/cxx/UtilsTest.cpp +2 -0
  134. data/test/integration_tests/apache2_tests.rb +2 -2
  135. data/test/integration_tests/native_packaging_spec.rb +170 -0
  136. data/test/ruby/spec_helper.rb +0 -1
  137. data/test/stub/apache2/httpd.conf.erb +1 -1
  138. data/test/stub/nginx/nginx.conf.erb +1 -0
  139. data/test/support/apache2_controller.rb +1 -1
  140. data/test/support/placebo-preloader.rb +1 -1
  141. data/test/support/test_helper.rb +5 -2
  142. metadata +32 -26
  143. metadata.gz.asc +7 -7
  144. data/debian/compat +0 -1
  145. data/debian/control +0 -49
  146. data/debian/copyright +0 -20
  147. data/debian/libapache2-mod-passenger.install +0 -1
  148. data/debian/passenger-common.install +0 -4
  149. data/debian/passenger.conf +0 -4
  150. data/debian/prerm +0 -2
  151. data/debian/rules +0 -37
  152. data/debian/watch +0 -3
  153. data/dev/googlecode_upload.py +0 -265
  154. data/ext/common/agents/HelperAgent/BacktracesServer.h +0 -60
  155. data/resources/templates/nginx/not_available_when_natively_packaged.txt.erb +0 -8
  156. data/test/stub/rails3.1/app/assets/javascripts/application.js +0 -9
  157. data/test/stub/rails3.2/app/assets/javascripts/application.js +0 -15
  158. data/test/stub/rails_apps/2.3/mycook/public/javascripts/application.js +0 -2
  159. data/test/stub/rails_apps/2.3/mycook/public/javascripts/controls.js +0 -963
  160. data/test/stub/rails_apps/2.3/mycook/public/javascripts/dragdrop.js +0 -973
  161. data/test/stub/rails_apps/2.3/mycook/public/javascripts/effects.js +0 -1128
  162. data/test/stub/rails_apps/2.3/mycook/public/javascripts/prototype.js +0 -4320
@@ -0,0 +1,3 @@
1
+ usr/lib/apache2/modules/
2
+ ../passenger.conf etc/apache2/mods-available
3
+ ../passenger.load etc/apache2/mods-available
@@ -0,0 +1,12 @@
1
+ [locations]
2
+ natively_packaged=true
3
+ bin=/usr/bin
4
+ agents=/usr/lib/passenger/agents
5
+ libdir=/usr/lib/passenger
6
+ helper_scripts=/usr/share/passenger/helper-scripts
7
+ resources=/usr/share/passenger
8
+ includedir=/usr/share/passenger/include
9
+ doc=/usr/share/doc/ruby-passenger
10
+ rubylibdir=/usr/lib/ruby/vendor_ruby
11
+ apache2_module=/usr/lib/apache2/modules/mod_passenger.so
12
+ ruby_extension_source=/usr/share/passenger/ruby_extension_source
@@ -0,0 +1,4 @@
1
+ <IfModule mod_passenger.c>
2
+ PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
3
+ PassengerDefaultRuby /usr/bin/ruby
4
+ </IfModule>
File without changes
@@ -0,0 +1,42 @@
1
+ #!/bin/sh
2
+ # Repackage upstream source to exclude non-distributable files
3
+ # should be called as "repack.sh --upstream-source <ver> <downloaded file>
4
+ # (for example, via uscan)
5
+
6
+ set -e
7
+ set -u
8
+
9
+ VER="$2debian"
10
+ FILE="$3"
11
+ PKG=`dpkg-parsechangelog|grep ^Source:|sed 's/^Source: //'`
12
+
13
+ REPACK_DIR="$PKG-$VER.orig" # DevRef § 6.7.8.2
14
+
15
+ echo -e "\nRepackaging $FILE\n"
16
+
17
+ DIR=`mktemp -d ./tmpRepackXXXXXX`
18
+ trap "rm -rf \"$DIR\"" QUIT INT EXIT
19
+
20
+ # Create an extra directory to cope with rootless tarballs
21
+ UP_BASE="$DIR/unpack"
22
+ mkdir "$UP_BASE"
23
+ tar xzf "$FILE" -C "$UP_BASE"
24
+
25
+ if [ `ls -1 "$UP_BASE" | wc -l` -eq 1 ]; then
26
+ # Tarball does contain a root directory
27
+ UP_BASE="$UP_BASE/`ls -1 "$UP_BASE"`"
28
+ fi
29
+
30
+ ## Remove stuff
31
+ rm -vfr $UP_BASE/test/support/valgrind.h
32
+ rm -vfr $UP_BASE/debian
33
+
34
+ mv "$UP_BASE" "$DIR/$REPACK_DIR"
35
+
36
+ # Using a pipe hides tar errors!
37
+ tar cfC "$DIR/repacked.tar" "$DIR" "$REPACK_DIR"
38
+ gzip -9 < "$DIR/repacked.tar" > "$DIR/repacked.tar.gz"
39
+ FILE="../${PKG}_${VER}.orig.tar.gz"
40
+ mv "$DIR/repacked.tar.gz" "$FILE"
41
+
42
+ echo "*** $FILE repackaged"
@@ -0,0 +1,3 @@
1
+ usr/share/passenger/ngx_http_passenger_module
2
+ usr/share/passenger/include/
3
+ usr/lib/passenger/common/
@@ -0,0 +1,2 @@
1
+ debian/tmp/usr/share/doc/passenger/* usr/share/doc/ruby-passenger/
2
+ CONTRIBUTORS usr/share/doc/ruby-passenger/
@@ -0,0 +1,4 @@
1
+ CONTRIBUTING.md
2
+ README.md
3
+ NEWS
4
+ debian/README.Debian
@@ -0,0 +1,11 @@
1
+ usr/lib/passenger/agents/
2
+ usr/share/passenger/helper-scripts/
3
+ usr/share/passenger/templates/
4
+ usr/share/passenger/standalone_default_root/
5
+ usr/share/passenger/ruby_extension_source/
6
+ usr/share/passenger/*.types
7
+ usr/share/passenger/*.crt
8
+ usr/lib/ruby/
9
+ debian/locations.ini usr/lib/ruby/vendor_ruby/phusion_passenger/
10
+ usr/sbin/
11
+ usr/bin/
@@ -0,0 +1,4 @@
1
+ man/passenger-memory-stats.8
2
+ man/passenger-status.8
3
+ man/passenger-config.1
4
+ man/passenger-stress-test.1
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/make -f
2
+ # export DH_VERBOSE=1
3
+
4
+ export USE_VENDORED_LIBEV=false
5
+
6
+ #if ['1', 'true', 'on', 'yes'].include?(ENV['USE_CCACHE'])
7
+ export USE_CCACHE=1
8
+ #endif
9
+
10
+ %:
11
+ dh $@
12
+
13
+ override_dh_auto_configure:
14
+ # Do nothing
15
+
16
+ override_dh_auto_build:
17
+ /usr/bin/ruby1.8 /usr/bin/rake fakeroot
18
+ mv pkg/fakeroot pkg/fakeroot1.8
19
+ /usr/bin/ruby1.9.1 /usr/bin/rake fakeroot
20
+ mv pkg/fakeroot pkg/fakeroot1.9.1
21
+
22
+ override_dh_auto_install:
23
+ mkdir debian/tmp/
24
+ # Merge Ruby 1.8 and 1.9 files into a single directory.
25
+ cp -a pkg/fakeroot1.8/* debian/tmp/
26
+ cp -a pkg/fakeroot1.9.1/* debian/tmp/
27
+ # Do not package Passenger Standalone.
28
+ rm -rf debian/tmp/usr/bin/passenger
29
+
30
+ override_dh_auto_clean:
31
+ /usr/bin/rake clean CLEAN_DOCS=false
32
+ rm -rf pkg/fakeroot1.8
33
+ rm -rf pkg/fakeroot1.9.1
34
+ # Hack to prevent HTML files from being renegerated
35
+ touch doc/*.html
@@ -0,0 +1 @@
1
+ 3.0 (quilt)
@@ -0,0 +1,3 @@
1
+ version=3
2
+ options="dversionmangle=s/debian[0-9]*//" \
3
+ http://rubyforge.org/frs/?group_id=5873 .*passenger-([\d.-]*)\.t.* debian debian/repack.sh
@@ -15,70 +15,70 @@ sudo sh -c 'cat >> /etc/hosts' <<EOF
15
15
  127.0.0.1 7.passenger.test 8.passenger.test 9.passenger.test
16
16
  EOF
17
17
 
18
+ function run()
19
+ {
20
+ echo "$ $@"
21
+ "$@"
22
+ }
23
+
18
24
  if [[ "$TEST_RUBY_VERSION" != "" ]]; then
19
25
  echo "$ rvm use $TEST_RUBY_VERSION"
20
- source ~/.rvm/scripts/rvm
26
+ if [[ -f ~/.rvm/scripts/rvm ]]; then
27
+ source ~/.rvm/scripts/rvm
28
+ else
29
+ source /usr/local/rvm/scripts/rvm
30
+ fi
21
31
  rvm use $TEST_RUBY_VERSION
22
32
  if [[ "$TEST_RUBYGEMS_VERSION" = "" ]]; then
23
- echo "$ gem --version"
24
- gem --version
33
+ run gem --version
25
34
  fi
26
35
  fi
27
36
 
28
37
  if [[ "$TEST_RUBYGEMS_VERSION" != "" ]]; then
29
- echo "$ rvm install rubygems $TEST_RUBYGEMS_VERSION"
30
- rvm install rubygems $TEST_RUBYGEMS_VERSION
31
- echo "$ gem --version"
32
- gem --version
33
- fi
34
-
35
- if [[ "$TEST_FULL_COMPILE" = 1 ]]; then
36
- echo "$ gem install rack --no-rdoc --no-ri"
37
- gem install rack --no-rdoc --no-ri
38
- echo "$ ./bin/passenger-install-apache2-module --auto"
39
- ./bin/passenger-install-apache2-module --auto
40
- echo "$ rake nginx"
41
- rake nginx
42
- echo "$ rake test/cxx/CxxTestMain"
43
- rake test/cxx/CxxTestMain
44
- echo "$ rake test/oxt/oxt_test_main"
45
- rake test/oxt/oxt_test_main
38
+ run rvm install rubygems $TEST_RUBYGEMS_VERSION
39
+ run gem --version
46
40
  fi
47
41
 
48
42
  if [[ "$TEST_CXX" = 1 ]]; then
49
- echo "$ rake test:install_deps RAILS_BUNDLES=no"
50
- rake test:install_deps RAILS_BUNDLES=no
51
- echo "$ rake test:cxx"
52
- rake test:cxx
53
- echo "$ rake test:oxt"
54
- rake test:oxt
43
+ run rake test:install_deps RAILS_BUNDLES=no DOCTOOLS=no
44
+ run rake test:cxx
45
+ run rake test:oxt
55
46
  fi
56
47
 
57
48
  if [[ "$TEST_RUBY" = 1 ]]; then
58
- echo "$ rake test:install_deps"
59
- rake test:install_deps
60
- echo "$ rake test:ruby"
61
- rake test:ruby
49
+ run rake test:install_deps DOCTOOLS=no
50
+ run rake test:ruby
62
51
  fi
63
52
 
64
53
  if [[ "$TEST_NGINX" = 1 ]]; then
65
- echo "$ rake test:install_deps RAILS_BUNDLES=no"
66
- rake test:install_deps RAILS_BUNDLES=no
67
- echo "$ gem install rack daemon_controller --no-rdoc --no-ri"
68
- gem install rack daemon_controller --no-rdoc --no-ri
69
- echo "$ ./bin/passenger-install-nginx-module --auto --prefix=/tmp/nginx --auto-download"
70
- ./bin/passenger-install-nginx-module --auto --prefix=/tmp/nginx --auto-download
71
- echo "$ rake test:integration:nginx"
72
- rake test:integration:nginx
54
+ run rake test:install_deps RAILS_BUNDLES=no DOCTOOLS=no
55
+ run gem install rack daemon_controller --no-rdoc --no-ri
56
+ run ./bin/passenger-install-nginx-module --auto --prefix=/tmp/nginx --auto-download
57
+ run rake test:integration:nginx
73
58
  fi
74
59
 
75
60
  if [[ "$TEST_APACHE2" = 1 ]]; then
76
- echo "$ rake test:install_deps RAILS_BUNDLES=no"
77
- rake test:install_deps RAILS_BUNDLES=no
78
- echo "$ gem install rack --no-rdoc --no-ri"
79
- gem install rack --no-rdoc --no-ri
80
- echo "$ rake apache2"
81
- rake apache2
82
- echo "$ rake test:integration:apache2"
83
- rake test:integration:apache2
61
+ run sudo apt-get install -y --no-install-recommends \
62
+ apache2-mpm-worker apache2-threaded-dev
63
+ run rake test:install_deps RAILS_BUNDLES=no DOCTOOLS=no
64
+ run gem install rack --no-rdoc --no-ri
65
+ run ./bin/passenger-install-apache2-module --auto
66
+ run rake test:integration:apache2
67
+ fi
68
+
69
+ if [[ "$TEST_DEBIAN_PACKAGING" = 1 ]]; then
70
+ run sudo apt-get install -y --no-install-recommends \
71
+ devscripts debhelper rake apache2-mpm-worker apache2-threaded-dev \
72
+ ruby1.8 ruby1.8-dev ruby1.9.1 ruby1.9.1-dev libev-dev gdebi-core \
73
+ source-highlight
74
+ run rake test:install_deps RAILS_BUNDLES=no
75
+ run rake debian:dev
76
+ run sudo gdebi -n pkg/ruby-passenger_*.deb
77
+ run sudo gdebi -n pkg/ruby-passenger-dev_*.deb
78
+ run sudo gdebi -n pkg/ruby-passenger-doc_*.deb
79
+ run sudo gdebi -n pkg/libapache2-mod-passenger_*.deb
80
+ run rvmsudo env LOCATIONS_INI=/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini \
81
+ rspec -f s -c test/integration_tests/native_packaging_spec.rb
82
+ run env PASSENGER_LOCATION_CONFIGURATION_FILE=/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini \
83
+ rake test:integration:apache2
84
84
  fi
@@ -1059,8 +1059,8 @@ pre {
1059
1059
  <body class="article">
1060
1060
  <div id="topbar" style="display: none">
1061
1061
  <div class="title">
1062
- <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAKCAYAAAEV95QVAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sGCRMSACDxkZwAAAAidEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVAgb24gYSBNYWOHqHdDAAAAZUlEQVQY032PSxbAIAjEIlfygL6ePF3UUvpzNjgSYWwqAMEhUQnANnsC7TQPeJpsVWzMuh2sog4vDTUbqP081zECrW4dtdaQGSIKlWluPyjK+VXxAz5XfcKufCzA130AfQHWB30HZxlPaP080xsAAAAASUVORK5CYII=" width="11" height="10" alt="">
1063
- <a href="javascript:void(Mizuho.smoothlyScrollToToc())">Phusion Passenger design &amp; architecture</a>
1062
+ <!-- Don't put a space between the img and a. That will break the hover layout. -->
1063
+ <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAKCAYAAAEV95QVAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sGCRMSACDxkZwAAAAidEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVAgb24gYSBNYWOHqHdDAAAAZUlEQVQY032PSxbAIAjEIlfygL6ePF3UUvpzNjgSYWwqAMEhUQnANnsC7TQPeJpsVWzMuh2sog4vDTUbqP081zECrW4dtdaQGSIKlWluPyjK+VXxAz5XfcKufCzA130AfQHWB30HZxlPaP080xsAAAAASUVORK5CYII=" width="11" height="10" alt=""><a href="javascript:void(Mizuho.smoothlyScrollToToc())">Phusion Passenger design &amp; architecture</a>
1064
1064
  </div>
1065
1065
  <a href="javascript:void(0)" id="current_section"></a>
1066
1066
  </div>
@@ -481,28 +481,35 @@ button.btn.btn-mini,input[type="submit"].btn.btn-mini{*padding-top:1px;*padding-
481
481
 
482
482
  <h1>Introduction</h1>
483
483
 
484
+ <p>This document describes how packagers can package Phusion Passenger binaries
485
+ for their operating system.</p>
486
+
484
487
  <p>Phusion Passenger can be configured in 2 ways, the "originally packaged"
485
- configuration and the "natively packaged" configuration. Depending on the
486
- configuration, Phusion Passenger locates its files (also called <em>assets</em>)
487
- in a different manner.</p>
488
+ configuration where everything is in the same directory, and the
489
+ "natively packaged" configuration where files are scattered across the
490
+ filesystem, e.g. in a FHS-compliant configuration. This document describes
491
+ how you can configure Phusion Passenger to locate its own files when they're
492
+ scattered across the filesystem.</p>
493
+
494
+ <p>Phusion Passenger files are also called <em>assets</em> in this document.</p>
488
495
 
489
496
  <h2>Originally packaged</h2>
490
497
 
491
498
  <p>This is the configuration you get when you checkout Phusion Passenger from git,
492
- when you install Phusion Passenger from a gem or when you extract it from a tarball.
493
- All the original files are stored in a single directory tree, which we call the
494
- <em>source root</em>.</p>
499
+ when you install Phusion Passenger from a gem or when you extract it from a
500
+ tarball. All the original files are stored in a single directory tree, which we
501
+ call the <em>source root</em>.</p>
495
502
 
496
- <p>This configuration does not come with any binaries; they have to be compiled by the
497
- user. Binaries may either be located in the source root, or located in a different
498
- location. The following rules apply when it comes to looking for binaries and
499
- determining where to store compiled binaries:</p>
503
+ <p>The git repository, gems and tarballs do not come with any binaries; they have
504
+ to be compiled by the user. Phusion Passenger looks for binaries in, and (if
505
+ the user initiates the compilation process) stores binaries in, the following
506
+ directories:</p>
500
507
 
501
508
  <ul>
502
- <li>It will normally look for binaries in a subdirectory under the source root, and
503
- it will store compiled binaries in a subdirectory under the source root.</li>
504
- <li><p>Phusion Passenger Standalone does things a little differently. It looks for
505
- its binaries in one of these places, whichever first exists:</p>
509
+ <li>Normally, binaries are to be located in the <code>agents</code> and <code>libout</code>
510
+ subdirectories under the source root.</li>
511
+ <li><p>Phusion Passenger Standalone does things a little differently. Binaries are
512
+ to be located in one of the following directories, whichever it finds first:</p>
506
513
 
507
514
  <ul>
508
515
  <li><code>~/.passenger/standalone/&lt;VERSION&gt;/&lt;TYPE-AND-ARCH&gt;</code> (a)</li>
@@ -510,9 +517,9 @@ its binaries in one of these places, whichever first exists:</p>
510
517
  </ul>
511
518
 
512
519
 
513
- <p>If neither directories exist, then Passenger Standalone compiles the binaries and
514
- stores them in (b) (when running as root) or in (a). It still looks for everything
515
- else (like the .rb files) in the source root.</p></li>
520
+ <p>If neither directories exist, then Passenger Standalone compiles the
521
+ binaries and stores them in (b) (when running as root) or in (a). It still
522
+ looks for everything else (like the .rb files) in the source root.</p></li>
516
523
  </ul>
517
524
 
518
525
 
@@ -718,7 +725,9 @@ print an example configuration snippet.</p>
718
725
  <li><p><code>ruby_extension_source</code></p>
719
726
 
720
727
  <p>The directory that contains the source code for the Phusion Passenger Ruby
721
- extension.</p>
728
+ extension. Phusion Passenger uses these sources to build a Ruby extension,
729
+ when it detects that the user is using a new Ruby interpeter for which
730
+ no Ruby extension has been compiled.</p>
722
731
 
723
732
  <p>Value when originally packaged: <code>&lt;SOURCE_ROOT&gt;/ext/ruby</code>.</p></li>
724
733
  </ul>
@@ -1,33 +1,40 @@
1
1
  # Introduction
2
2
 
3
+ This document describes how packagers can package Phusion Passenger binaries
4
+ for their operating system.
5
+
3
6
  Phusion Passenger can be configured in 2 ways, the "originally packaged"
4
- configuration and the "natively packaged" configuration. Depending on the
5
- configuration, Phusion Passenger locates its files (also called _assets_)
6
- in a different manner.
7
+ configuration where everything is in the same directory, and the
8
+ "natively packaged" configuration where files are scattered across the
9
+ filesystem, e.g. in a FHS-compliant configuration. This document describes
10
+ how you can configure Phusion Passenger to locate its own files when they're
11
+ scattered across the filesystem.
12
+
13
+ Phusion Passenger files are also called _assets_ in this document.
7
14
 
8
15
  ## Originally packaged
9
16
 
10
17
  This is the configuration you get when you checkout Phusion Passenger from git,
11
- when you install Phusion Passenger from a gem or when you extract it from a tarball.
12
- All the original files are stored in a single directory tree, which we call the
13
- _source root_.
18
+ when you install Phusion Passenger from a gem or when you extract it from a
19
+ tarball. All the original files are stored in a single directory tree, which we
20
+ call the _source root_.
14
21
 
15
- This configuration does not come with any binaries; they have to be compiled by the
16
- user. Binaries may either be located in the source root, or located in a different
17
- location. The following rules apply when it comes to looking for binaries and
18
- determining where to store compiled binaries:
22
+ The git repository, gems and tarballs do not come with any binaries; they have
23
+ to be compiled by the user. Phusion Passenger looks for binaries in, and (if
24
+ the user initiates the compilation process) stores binaries in, the following
25
+ directories:
19
26
 
20
- * It will normally look for binaries in a subdirectory under the source root, and
21
- it will store compiled binaries in a subdirectory under the source root.
22
- * Phusion Passenger Standalone does things a little differently. It looks for
23
- its binaries in one of these places, whichever first exists:
27
+ * Normally, binaries are to be located in the `agents` and `libout`
28
+ subdirectories under the source root.
29
+ * Phusion Passenger Standalone does things a little differently. Binaries are
30
+ to be located in one of the following directories, whichever it finds first:
24
31
 
25
32
  - `~/.passenger/standalone/<VERSION>/<TYPE-AND-ARCH>` (a)
26
33
  - `/var/lib/passenger-standalone/<VERSION-AND-ARCH>` (b)
27
34
 
28
- If neither directories exist, then Passenger Standalone compiles the binaries and
29
- stores them in (b) (when running as root) or in (a). It still looks for everything
30
- else (like the .rb files) in the source root.
35
+ If neither directories exist, then Passenger Standalone compiles the
36
+ binaries and stores them in (b) (when running as root) or in (a). It still
37
+ looks for everything else (like the .rb files) in the source root.
31
38
 
32
39
  ## Natively packaged
33
40
 
@@ -229,7 +236,9 @@ a list of all possible assets and asset directories.
229
236
  * `ruby_extension_source`
230
237
 
231
238
  The directory that contains the source code for the Phusion Passenger Ruby
232
- extension.
239
+ extension. Phusion Passenger uses these sources to build a Ruby extension,
240
+ when it detects that the user is using a new Ruby interpeter for which
241
+ no Ruby extension has been compiled.
233
242
 
234
243
  Value when originally packaged: `<SOURCE_ROOT>/ext/ruby`.
235
244
 
@@ -1059,8 +1059,8 @@ pre {
1059
1059
  <body class="article">
1060
1060
  <div id="topbar" style="display: none">
1061
1061
  <div class="title">
1062
- <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAKCAYAAAEV95QVAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sGCRMSACDxkZwAAAAidEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVAgb24gYSBNYWOHqHdDAAAAZUlEQVQY032PSxbAIAjEIlfygL6ePF3UUvpzNjgSYWwqAMEhUQnANnsC7TQPeJpsVWzMuh2sog4vDTUbqP081zECrW4dtdaQGSIKlWluPyjK+VXxAz5XfcKufCzA130AfQHWB30HZxlPaP080xsAAAAASUVORK5CYII=" width="11" height="10" alt="">
1063
- <a href="javascript:void(Mizuho.smoothlyScrollToToc())">Security of user switching support in Passenger</a>
1062
+ <!-- Don't put a space between the img and a. That will break the hover layout. -->
1063
+ <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAKCAYAAAEV95QVAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sGCRMSACDxkZwAAAAidEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVAgb24gYSBNYWOHqHdDAAAAZUlEQVQY032PSxbAIAjEIlfygL6ePF3UUvpzNjgSYWwqAMEhUQnANnsC7TQPeJpsVWzMuh2sog4vDTUbqP081zECrW4dtdaQGSIKlWluPyjK+VXxAz5XfcKufCzA130AfQHWB30HZxlPaP080xsAAAAASUVORK5CYII=" width="11" height="10" alt=""><a href="javascript:void(Mizuho.smoothlyScrollToToc())">Security of user switching support in Passenger</a>
1064
1064
  </div>
1065
1065
  <a href="javascript:void(0)" id="current_section"></a>
1066
1066
  </div>
@@ -1059,8 +1059,8 @@ pre {
1059
1059
  <body class="article">
1060
1060
  <div id="topbar" style="display: none">
1061
1061
  <div class="title">
1062
- <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAKCAYAAAEV95QVAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sGCRMSACDxkZwAAAAidEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVAgb24gYSBNYWOHqHdDAAAAZUlEQVQY032PSxbAIAjEIlfygL6ePF3UUvpzNjgSYWwqAMEhUQnANnsC7TQPeJpsVWzMuh2sog4vDTUbqP081zECrW4dtdaQGSIKlWluPyjK+VXxAz5XfcKufCzA130AfQHWB30HZxlPaP080xsAAAAASUVORK5CYII=" width="11" height="10" alt="">
1063
- <a href="javascript:void(Mizuho.smoothlyScrollToToc())">Phusion Passenger users guide, Apache version</a>
1062
+ <!-- Don't put a space between the img and a. That will break the hover layout. -->
1063
+ <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAKCAYAAAEV95QVAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sGCRMSACDxkZwAAAAidEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVAgb24gYSBNYWOHqHdDAAAAZUlEQVQY032PSxbAIAjEIlfygL6ePF3UUvpzNjgSYWwqAMEhUQnANnsC7TQPeJpsVWzMuh2sog4vDTUbqP081zECrW4dtdaQGSIKlWluPyjK+VXxAz5XfcKufCzA130AfQHWB30HZxlPaP080xsAAAAASUVORK5CYII=" width="11" height="10" alt=""><a href="javascript:void(Mizuho.smoothlyScrollToToc())">Phusion Passenger users guide, Apache version</a>
1064
1064
  </div>
1065
1065
  <a href="javascript:void(0)" id="current_section"></a>
1066
1066
  </div>
@@ -1111,7 +1111,7 @@ using the command line.</p></div>
1111
1111
  <div class="foo toclevel3"><a href="#_synopsis">2.1. Synopsis</a></div>
1112
1112
  <div class="foo toclevel3"><a href="#rubygems_generic_install">2.2. Generic installation, upgrade and downgrade method: via RubyGems</a></div>
1113
1113
  <div class="foo toclevel3"><a href="#tarball_generic_install">2.3. Generic installation, upgrade and downgrade method: via tarball</a></div>
1114
- <div class="foo toclevel3"><a href="#_installing_or_upgrading_on_debian_6_or_ubuntu">2.4. Installing or upgrading on Debian 6 or Ubuntu</a></div>
1114
+ <div class="foo toclevel3"><a href="#install_on_debian_ubuntu">2.4. Installing or upgrading on Debian 6 or Ubuntu</a></div>
1115
1115
  <div class="foo toclevel3"><a href="#_installing_or_upgrading_on_red_hat_fedora_centos_or_scientificlinux">2.5. Installing or upgrading on Red Hat, Fedora, CentOS or ScientificLinux</a></div>
1116
1116
  <div class="foo toclevel3"><a href="#_upgrading_from_open_source_to_enterprise">2.6. Upgrading from open source to Enterprise</a></div>
1117
1117
  <div class="foo toclevel3"><a href="#_cryptographic_verification_of_installation_files">2.7. Cryptographic verification of installation files</a></div>
@@ -1126,7 +1126,7 @@ using the command line.</p></div>
1126
1126
  <div class="foo toclevel3"><a href="#_customizing_the_compilation_process">2.9. Customizing the compilation process</a></div>
1127
1127
  <div class="foo toclevel4"><a href="#_setting_the_compiler">2.9.1. Setting the compiler</a></div>
1128
1128
  <div class="foo toclevel4"><a href="#_adding_additional_compiler_or_linker_flags">2.9.2. Adding additional compiler or linker flags</a></div>
1129
- <div class="foo toclevel4"><a href="#_forcing_location_of_certain_command_line_tools">2.9.3. Forcing location of certain command line tools</a></div>
1129
+ <div class="foo toclevel4"><a href="#_forcing_location_of_command_line_tools_and_dependencies">2.9.3. Forcing location of command line tools and dependencies</a></div>
1130
1130
  <div class="foo toclevel3"><a href="#working_with_apache_conf">2.10. Working with the Apache configuration file</a></div>
1131
1131
  <div class="foo toclevel3"><a href="#_disabling_without_uninstalling">2.11. Disabling without uninstalling</a></div>
1132
1132
  <div class="foo toclevel3"><a href="#uninstalling">2.12. Uninstalling</a></div>
@@ -1155,7 +1155,7 @@ using the command line.</p></div>
1155
1155
  <div class="foo toclevel3"><a href="#_redeploying_restarting_the_wsgi_application">5.3. Redeploying (restarting the WSGI application)</a></div>
1156
1156
  <div class="foo toclevel2"><a href="#_configuring_phusion_passenger">6. Configuring Phusion Passenger</a></div>
1157
1157
  <div class="foo toclevel3"><a href="#_passengerroot_lt_directory_gt">6.1. PassengerRoot &lt;directory&gt;</a></div>
1158
- <div class="foo toclevel3"><a href="#PassengerDefaultRuby">6.2. PassengerDefaultRuby and PassengerRuby</a></div>
1158
+ <div class="foo toclevel3"><a href="#PassengerDefaultRuby">6.2. PassengerDefaultRuby &lt;filename&gt;</a></div>
1159
1159
  <div class="foo toclevel3"><a href="#PassengerRuby">6.3. PassengerRuby &lt;filename&gt;</a></div>
1160
1160
  <div class="foo toclevel3"><a href="#_passengerpython_lt_filename_gt">6.4. PassengerPython &lt;filename&gt;</a></div>
1161
1161
  <div class="foo toclevel3"><a href="#PassengerAppRoot">6.5. PassengerAppRoot &lt;path/to/root&gt;</a></div>
@@ -1169,11 +1169,11 @@ using the command line.</p></div>
1169
1169
  <div class="foo toclevel3"><a href="#_passengerresistdeploymenterrors_lt_on_off_gt">6.13. PassengerResistDeploymentErrors &lt;on|off&gt;</a></div>
1170
1170
  <div class="foo toclevel3"><a href="#_security_options">6.14. Security options</a></div>
1171
1171
  <div class="foo toclevel4"><a href="#PassengerUserSwitching">6.14.1. PassengerUserSwitching &lt;on|off&gt;</a></div>
1172
- <div class="foo toclevel4"><a href="#_passengeruser_lt_username_gt">6.14.2. PassengerUser &lt;username&gt;</a></div>
1173
- <div class="foo toclevel4"><a href="#_passengergroup_lt_group_name_gt">6.14.3. PassengerGroup &lt;group name&gt;</a></div>
1172
+ <div class="foo toclevel4"><a href="#PassengerUser">6.14.2. PassengerUser &lt;username&gt;</a></div>
1173
+ <div class="foo toclevel4"><a href="#PassengerGroup">6.14.3. PassengerGroup &lt;group name&gt;</a></div>
1174
1174
  <div class="foo toclevel4"><a href="#PassengerDefaultUser">6.14.4. PassengerDefaultUser &lt;username&gt;</a></div>
1175
1175
  <div class="foo toclevel4"><a href="#PassengerDefaultGroup">6.14.5. PassengerDefaultGroup &lt;group name&gt;</a></div>
1176
- <div class="foo toclevel4"><a href="#_passengerfriendlyerrorpages_lt_on_off_gt">6.14.6. PassengerFriendlyErrorPages &lt;on|off&gt;</a></div>
1176
+ <div class="foo toclevel4"><a href="#PassengerFriendlyErrorPages">6.14.6. PassengerFriendlyErrorPages &lt;on|off&gt;</a></div>
1177
1177
  <div class="foo toclevel3"><a href="#_resource_control_and_optimization_options">6.15. Resource control and optimization options</a></div>
1178
1178
  <div class="foo toclevel4"><a href="#_passengermaxpoolsize_lt_integer_gt">6.15.1. PassengerMaxPoolSize &lt;integer&gt;</a></div>
1179
1179
  <div class="foo toclevel4"><a href="#PassengerMinInstances">6.15.2. PassengerMinInstances &lt;integer&gt;</a></div>
@@ -1193,7 +1193,7 @@ using the command line.</p></div>
1193
1193
  <div class="foo toclevel4"><a href="#PassengerResolveSymlinksInDocumentRoot">6.16.1. PassengerResolveSymlinksInDocumentRoot &lt;on|off&gt;</a></div>
1194
1194
  <div class="foo toclevel4"><a href="#_passengerallowencodedslashes_lt_on_off_gt">6.16.2. PassengerAllowEncodedSlashes &lt;on|off&gt;</a></div>
1195
1195
  <div class="foo toclevel3"><a href="#_logging_and_debugging_options">6.17. Logging and debugging options</a></div>
1196
- <div class="foo toclevel4"><a href="#_passengerloglevel_lt_integer_gt">6.17.1. PassengerLogLevel &lt;integer&gt;</a></div>
1196
+ <div class="foo toclevel4"><a href="#PassengerLogLevel">6.17.1. PassengerLogLevel &lt;integer&gt;</a></div>
1197
1197
  <div class="foo toclevel4"><a href="#_passengerdebuglogfile_lt_filename_gt">6.17.2. PassengerDebugLogFile &lt;filename&gt;</a></div>
1198
1198
  <div class="foo toclevel4"><a href="#_passengerdebugger_lt_on_off_gt">6.17.3. PassengerDebugger &lt;on|off&gt;</a></div>
1199
1199
  <div class="foo toclevel3"><a href="#_classic_ruby_on_rails_8656_2_x_specific_options">6.18. Classic Ruby on Rails (⇐ 2.x)-specific options</a></div>
@@ -1240,16 +1240,27 @@ using the command line.</p></div>
1240
1240
  <div class="foo toclevel3"><a href="#_accessing_individual_application_processes">8.4. Accessing individual application processes</a></div>
1241
1241
  <div class="foo toclevel3"><a href="#_attaching_an_irb_console_to_an_application_process">8.5. Attaching an IRB console to an application process</a></div>
1242
1242
  <div class="foo toclevel2"><a href="#_tips">9. Tips</a></div>
1243
- <div class="foo toclevel3"><a href="#user_switching">9.1. User switching (security)</a></div>
1244
- <div class="foo toclevel3"><a href="#reducing_memory_usage">9.2. Reducing memory consumption of Ruby on Rails applications by 33%</a></div>
1243
+ <div class="foo toclevel3"><a href="#user_switching">9.1. User Switching (security feature)</a></div>
1244
+ <div class="foo toclevel4"><a href="#_requirements">9.1.1. Requirements</a></div>
1245
+ <div class="foo toclevel4"><a href="#_effects">9.1.2. Effects</a></div>
1246
+ <div class="foo toclevel4"><a href="#_caveats_amp_troubleshooting">9.1.3. Caveats &amp; troubleshooting</a></div>
1247
+ <div class="foo toclevel4"><a href="#finding_out_app_user">9.1.4. Finding out what user an application is running as</a></div>
1248
+ <div class="foo toclevel3"><a href="#reducing_memory_usage">9.2. Copy-on-write memory support (reducing memory consumption of Ruby applications)</a></div>
1245
1249
  <div class="foo toclevel3"><a href="#capistrano">9.3. Capistrano recipe</a></div>
1246
1250
  <div class="foo toclevel3"><a href="#bundler_support">9.4. Bundler support</a></div>
1251
+ <div class="foo toclevel4"><a href="#add_passenger_to_gemfile">9.4.1. Does Phusion Passenger itself need to be added to the Gemfile?</a></div>
1247
1252
  <div class="foo toclevel3"><a href="#_installing_multiple_ruby_on_rails_versions">9.5. Installing multiple Ruby on Rails versions</a></div>
1248
1253
  <div class="foo toclevel3"><a href="#_making_the_application_restart_after_each_request">9.6. Making the application restart after each request</a></div>
1249
1254
  <div class="foo toclevel3"><a href="#sub_uri_deployment_uri_fix">9.7. How to fix broken images/CSS/JavaScript URIs in sub-URI deployments</a></div>
1250
1255
  <div class="foo toclevel3"><a href="#_out_of_band_garbage_work_and_out_of_band_garbage_collection">9.8. Out-of-Band Garbage Work and Out-of-Band Garbage Collection</a></div>
1251
- <div class="foo toclevel3"><a href="#_x_sendfile_support">9.9. X-Sendfile support</a></div>
1252
- <div class="foo toclevel3"><a href="#_upload_progress">9.10. Upload progress</a></div>
1256
+ <div class="foo toclevel3"><a href="#flying_passenger">9.9. Flying Passenger</a></div>
1257
+ <div class="foo toclevel4"><a href="#_requirements_2">9.9.1. Requirements</a></div>
1258
+ <div class="foo toclevel4"><a href="#_basic_usage">9.9.2. Basic usage</a></div>
1259
+ <div class="foo toclevel4"><a href="#configuring_flying_passenger">9.9.3. Configuring Flying Passenger</a></div>
1260
+ <div class="foo toclevel4"><a href="#_managing_the_flying_passenger_daemon">9.9.4. Managing the Flying Passenger daemon</a></div>
1261
+ <div class="foo toclevel4"><a href="#flying_passenger_caveats">9.9.5. Caveats and limitations</a></div>
1262
+ <div class="foo toclevel3"><a href="#_x_sendfile_support">9.10. X-Sendfile support</a></div>
1263
+ <div class="foo toclevel3"><a href="#_upload_progress">9.11. Upload progress</a></div>
1253
1264
  <div class="foo toclevel2"><a href="#_under_the_hood">10. Under the hood</a></div>
1254
1265
  <div class="foo toclevel3"><a href="#_static_assets_serving">10.1. Static assets serving</a></div>
1255
1266
  <div class="foo toclevel3"><a href="#_page_caching_support">10.2. Page caching support</a></div>
@@ -1269,6 +1280,16 @@ using the command line.</p></div>
1269
1280
  <div class="foo toclevel4"><a href="#_example_2_log_file_sharing_not_harmful">13.3.2. Example 2: Log file sharing (not harmful)</a></div>
1270
1281
  <div class="foo toclevel3"><a href="#_smart_spawning_gotcha_2_the_need_to_revive_threads">13.4. Smart spawning gotcha #2: the need to revive threads</a></div>
1271
1282
  <div class="foo toclevel3"><a href="#_smart_spawning_gotcha_3_code_load_order">13.5. Smart spawning gotcha #3: code load order</a></div>
1283
+ <div class="foo toclevel2"><a href="#about_environment_variables">14. Appendix D: About environment variables</a></div>
1284
+ <div class="foo toclevel3"><a href="#_working_with_environment_variables">14.1. Working with environment variables</a></div>
1285
+ <div class="foo toclevel3"><a href="#_the_path_environment_variable">14.2. The PATH environment variable</a></div>
1286
+ <div class="foo toclevel3"><a href="#_making_environment_variables_permanent">14.3. Making environment variables permanent</a></div>
1287
+ <div class="foo toclevel4"><a href="#_bash">14.3.1. bash</a></div>
1288
+ <div class="foo toclevel4"><a href="#_apache">14.3.2. Apache</a></div>
1289
+ <div class="foo toclevel4"><a href="#_nginx">14.3.3. Nginx</a></div>
1290
+ <div class="foo toclevel4"><a href="#_cron">14.3.4. cron</a></div>
1291
+ <div class="foo toclevel4"><a href="#env_vars_passenger_apps">14.3.5. Phusion Passenger-served apps</a></div>
1292
+ <div class="foo toclevel3"><a href="#env_vars_and_sudo">14.4. Environment variables and sudo</a></div>
1272
1293
  </div>
1273
1294
  </div>
1274
1295
  <div id="content">
@@ -1295,14 +1316,14 @@ if it doesn’t work on your POSIX-compliant operating system.</p></div>
1295
1316
  <div class="ulist"><ul>
1296
1317
  <li>
1297
1318
  <p>
1298
- <a href="http://code.google.com/p/phusion-passenger/issues/list">Issue tracker</a> - report
1299
- bugs here.
1319
+ <a href="http://groups.google.com/group/phusion-passenger">Discussion forum</a> - post a
1320
+ message here if you’re experiencing problems. Support on this forum is provided by the community on a best-effort basis, so a (timely) response is not guaranteed.
1300
1321
  </p>
1301
1322
  </li>
1302
1323
  <li>
1303
1324
  <p>
1304
- <a href="http://groups.google.com/group/phusion-passenger">Discussion forum</a> - post a
1305
- message here if you’re experiencing problems. Support on this forum is provided by the community on a best-effort basis, so a (timely) response is not guaranteed.
1325
+ <a href="http://code.google.com/p/phusion-passenger/issues/list">Issue tracker</a> - report
1326
+ bugs here.
1306
1327
  </p>
1307
1328
  </li>
1308
1329
  <li>
@@ -1317,7 +1338,7 @@ Email <a href="mailto:support@phusion.nl">support@phusion.nl</a> if you are a <a
1317
1338
  </li>
1318
1339
  <li>
1319
1340
  <p>
1320
- Report security vulnerabilities to <a href="mailto:support@phusion.nl">support@phusion.nl</a>. We will do our best to respond to you as quickly as we can, so please do not disclose the vulnerability until then.
1341
+ Report security vulnerabilities to <a href="mailto:security@phusion.nl">security@phusion.nl</a>. We will do our best to respond to you as quickly as we can, so please do not disclose the vulnerability until then.
1321
1342
  </p>
1322
1343
  </li>
1323
1344
  </ul></div>
@@ -1478,7 +1499,21 @@ chmod o+x /home/phusion</pre>
1478
1499
  configuration file. However, it doesn’t copy any files to outside the Phusion Passenger source directory.</p>
1479
1500
  </div>
1480
1501
  <div class="paragraph"><p><span class="monospaced">passenger-install-apache2-module</span> is actually just a user-friendly frontend around the command <span class="monospaced">rake apache2</span>, which performs the actual compilation of Phusion Passenger.</p></div>
1481
- <span class="anchor_helper" id="verify_passenger_running"></span><h4 class="float" data-anchor="verify_passenger_running">Step 6: Verifying that Phusion Passenger is running</h4>
1502
+ <span class="anchor_helper" id="_step_6_restarting_the_flying_passenger_daemon"></span><h4 class="float" data-anchor="_step_6_restarting_the_flying_passenger_daemon">Step 6: Restarting the Flying Passenger daemon</h4>
1503
+ <div class="paragraph"><p>If you are using <a href="#flying_passenger">Flying Passenger</a> then you must restart the Flying Passenger daemon by sending it the SIGTERM signal:</p></div>
1504
+ <div class="listingblock">
1505
+ <div class="content monospaced">
1506
+ <pre>kill `cat /path-to/flying-passenger.pid`</pre>
1507
+ </div>
1508
+ </div>
1509
+ <div class="paragraph"><p>Or, if Flying Passenger is not running with a PID file, look up its PID us <span class="monospaced">ps</span> and then send it SIGTERM:</p></div>
1510
+ <div class="listingblock">
1511
+ <div class="content monospaced">
1512
+ <pre>ps auxw | grep flying-passenger
1513
+ kill PID_OF_FLYING_PASSENGER</pre>
1514
+ </div>
1515
+ </div>
1516
+ <span class="anchor_helper" id="verify_passenger_running"></span><h4 class="float" data-anchor="verify_passenger_running">Step 7: Verifying that Phusion Passenger is running</h4>
1482
1517
  <div class="paragraph"><p>Restart your web server and run:</p></div>
1483
1518
  <div class="listingblock">
1484
1519
  <div class="content monospaced">
@@ -1491,24 +1526,7 @@ configuration file. However, it doesn’t copy any files to outside the Phusion
1491
1526
  <div class="sect2">
1492
1527
  <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="tarball_generic_install"></span><h3 data-comment-topic="installing-via-the-source-tarball-1cgxrqc" data-anchor="tarball_generic_install">2.3. Generic installation, upgrade and downgrade method: via tarball</h3>
1493
1528
  <span class="anchor_helper" id="_step_1_download_and_extract_the_tarball"></span><h4 class="float" data-anchor="_step_1_download_and_extract_the_tarball">Step 1: download and extract the tarball</h4>
1494
- <div class="paragraph"><p>Download the open source Phusion Passenger tarball from <a href="https://www.phusionpassenger.com/download#open_source">the Phusion Passenger website</a>. Specific older versions are not found on the Phusion Passenger website, but are found in the following places:</p></div>
1495
- <div class="ulist"><ul>
1496
- <li>
1497
- <p>
1498
- All versions starting from 4.0.0 can be found on <a href="https://code.google.com/p/phusion-passenger/downloads/list">Google Code</a>.
1499
- </p>
1500
- </li>
1501
- <li>
1502
- <p>
1503
- All versions prior to 4.0.0, except for beta releases and Release Candidates, can be found on <a href="http://rubyforge.org/frs/?group_id=5873&amp;release_id=46919">RubyForge</a>.
1504
- </p>
1505
- </li>
1506
- <li>
1507
- <p>
1508
- All beta releases and Release Candidates prior to 4.0.0 beta 1 can be found on <a href="https://code.google.com/p/phusion-passenger/downloads/list">Google Code</a>.
1509
- </p>
1510
- </li>
1511
- </ul></div>
1529
+ <div class="paragraph"><p>Download the open source Phusion Passenger tarball from <a href="https://www.phusionpassenger.com/download#open_source">the Phusion Passenger website</a>. Older versions can be found on <a href="https://www.phusionpassenger.com/file_releases">the release archive</a>.</p></div>
1512
1530
  <div class="paragraph"><p>If you a <a href="https://www.phusionpassenger.com/enterprise">Phusion Passenger Enterprise</a> customer, download the Phusion Passenger Enterprise tarball from the <a href="https://www.phusionpassenger.com/orders">Customer Area</a>. Also be sure to download the <strong>license key</strong> and save it as <em>/etc/passenger-enterprise-license</em>.</p></div>
1513
1531
  <div class="paragraph"><p>Once you have downloaded the tarball, pick a location to extract it to. You can pick any location. A good location is <em>/opt/passenger</em>. Let’s call this location <span class="monospaced">$PREFIX</span>. Create this directory and extract the tarball as follows:</p></div>
1514
1532
  <div class="listingblock">
@@ -1601,11 +1619,25 @@ sudo apt-get update</pre>
1601
1619
  <span class="anchor_helper" id="_step_5_run_the_phusion_passenger_installer"></span><h4 class="float" data-anchor="_step_5_run_the_phusion_passenger_installer">Step 5: run the Phusion Passenger installer</h4>
1602
1620
  <div class="paragraph"><p>Please refer to <a href="#run_passenger_installer">this section</a>.
1603
1621
  Note that the <span class="monospaced">passenger-install-apache2-module</span> command is inside the <em>bin</em> subdirectory of the Phusion Passenger source directory, so you would have to run something like <em>/opt/passenger/passenger-x.x.x/bin/passenger-install-apache2-module</em>.</p></div>
1604
- <span class="anchor_helper" id="_step_6_verifying_that_phusion_passenger_is_running"></span><h4 class="float" data-anchor="_step_6_verifying_that_phusion_passenger_is_running">Step 6: Verifying that Phusion Passenger is running</h4>
1622
+ <span class="anchor_helper" id="_step_6_restarting_the_flying_passenger_daemon_2"></span><h4 class="float" data-anchor="_step_6_restarting_the_flying_passenger_daemon_2">Step 6: Restarting the Flying Passenger daemon</h4>
1623
+ <div class="paragraph"><p>If you are using <a href="#flying_passenger">Flying Passenger</a> then you must restart the Flying Passenger daemon by sending it the SIGTERM signal:</p></div>
1624
+ <div class="listingblock">
1625
+ <div class="content monospaced">
1626
+ <pre>kill `cat /path-to/flying-passenger.pid`</pre>
1627
+ </div>
1628
+ </div>
1629
+ <div class="paragraph"><p>Or, if Flying Passenger is not running with a PID file, look up its PID us <span class="monospaced">ps</span> and then send it SIGTERM:</p></div>
1630
+ <div class="listingblock">
1631
+ <div class="content monospaced">
1632
+ <pre>ps auxw | grep flying-passenger
1633
+ kill PID_OF_FLYING_PASSENGER</pre>
1634
+ </div>
1635
+ </div>
1636
+ <span class="anchor_helper" id="_step_7_verifying_that_phusion_passenger_is_running"></span><h4 class="float" data-anchor="_step_7_verifying_that_phusion_passenger_is_running">Step 7: Verifying that Phusion Passenger is running</h4>
1605
1637
  <div class="paragraph"><p>Please refer to <a href="#verify_passenger_running">this section</a>. Note that all Phusion Passenger administration scripts are located inside the <em>bin</em> subdirectory of the Phusion Passenger source directory, so you would have to run something like <em>/opt/passenger/passenger-x.x.x/bin/passenger-memory-stats</em>.</p></div>
1606
1638
  </div>
1607
1639
  <div class="sect2">
1608
- <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_installing_or_upgrading_on_debian_6_or_ubuntu"></span><h3 data-comment-topic="installing-or-upgrading-on-ubuntu-1xg22xs" data-anchor="_installing_or_upgrading_on_debian_6_or_ubuntu">2.4. Installing or upgrading on Debian 6 or Ubuntu</h3>
1640
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="install_on_debian_ubuntu"></span><h3 data-comment-topic="installing-or-upgrading-on-ubuntu-1xg22xs" data-anchor="install_on_debian_ubuntu">2.4. Installing or upgrading on Debian 6 or Ubuntu</h3>
1609
1641
  <div class="paragraph"><p>John Leach from Brightbox has kindly provided Ubuntu packages for Phusion Passenger. The Ubuntu Lucid packages are compatible with Debian 6. The packages are available from the <a href="http://wiki.brightbox.co.uk/docs:phusion-passenger">Brightbox repository</a>. Only packages for the open source version of Phusion Passenger are provided. <a href="https://www.phusionpassenger.com/enterprise">Phusion Passenger Enterprise</a> customers should use the <a href="#rubygems_generic_install">generic RubyGems installation method</a> or <a href="#tarball_generic_install">the generic tarball installation method</a> instead.</p></div>
1610
1642
  <div class="paragraph"><p>If you use these packages to install Phusion Passenger then you do not need to run <span class="monospaced">passenger-install-apache2-module</span> or <span class="monospaced">passenger-install-nginx-module</span>. These packages contain all the binaries that you need.</p></div>
1611
1643
  <div class="paragraph">
@@ -1614,7 +1646,7 @@ Note that the <span class="monospaced">passenger-install-apache2-module</span> c
1614
1646
  </div>
1615
1647
  <div class="listingblock">
1616
1648
  <div class="content monospaced">
1617
- <pre>sudo apt-add-repository ppa:brightbox/passenger
1649
+ <pre>sudo apt-add-repository ppa:brightbox/passenger-experimental
1618
1650
  sudo apt-get update</pre>
1619
1651
  </div>
1620
1652
  </div>
@@ -1622,7 +1654,7 @@ sudo apt-get update</pre>
1622
1654
  <div class="paragraph"><p>Debian 6:</p></div>
1623
1655
  <div class="listingblock">
1624
1656
  <div class="content monospaced">
1625
- <pre>sudo sh -c 'echo "deb http://ppa.launchpad.net/brightbox/passenger/ubuntu lucid main" &gt; /etc/apt/sources.list.d/brightbox-passenger.list'
1657
+ <pre>sudo sh -c 'echo "deb http://ppa.launchpad.net/brightbox/passenger-experimental/ubuntu lucid main" &gt; /etc/apt/sources.list.d/brightbox-passenger.list'
1626
1658
  sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C3173AA6
1627
1659
  sudo apt-get update</pre>
1628
1660
  </div>
@@ -1630,7 +1662,7 @@ sudo apt-get update</pre>
1630
1662
  <div class="paragraph"><p>Ubuntu 8.04 Hardy:</p></div>
1631
1663
  <div class="listingblock">
1632
1664
  <div class="content monospaced">
1633
- <pre>sudo sh -c 'echo "deb http://ppa.launchpad.net/brightbox/passenger/ubuntu hardy main" &gt; /etc/apt/sources.list.d/brightbox-passenger.list'
1665
+ <pre>sudo sh -c 'echo "deb http://ppa.launchpad.net/brightbox/passenger-experimental/ubuntu hardy main" &gt; /etc/apt/sources.list.d/brightbox-passenger.list'
1634
1666
  sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C3173AA6
1635
1667
  sudo apt-get update</pre>
1636
1668
  </div>
@@ -1648,7 +1680,7 @@ sudo apt-get update</pre>
1648
1680
  </div>
1649
1681
  <div class="listingblock">
1650
1682
  <div class="content monospaced">
1651
- <pre>sudo apt-add-repository ppa:brightbox/passenger-nginx
1683
+ <pre>sudo apt-add-repository ppa:brightbox/passenger-experimental
1652
1684
  sudo apt-get update</pre>
1653
1685
  </div>
1654
1686
  </div>
@@ -1656,7 +1688,7 @@ sudo apt-get update</pre>
1656
1688
  <div class="paragraph"><p>Debian 6:</p></div>
1657
1689
  <div class="listingblock">
1658
1690
  <div class="content monospaced">
1659
- <pre>sudo sh -c 'echo "deb http://ppa.launchpad.net/brightbox/passenger-nginx/ubuntu lucid main" &gt; /etc/apt/sources.list.d/brightbox-passenger-nginx.list'
1691
+ <pre>sudo sh -c 'echo "deb http://ppa.launchpad.net/brightbox/passenger-experimental/ubuntu lucid main" &gt; /etc/apt/sources.list.d/brightbox-passenger-nginx.list'
1660
1692
  sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C3173AA6
1661
1693
  sudo apt-get update</pre>
1662
1694
  </div>
@@ -1664,7 +1696,7 @@ sudo apt-get update</pre>
1664
1696
  <div class="paragraph"><p>Ubuntu 8.04 Hardy:</p></div>
1665
1697
  <div class="listingblock">
1666
1698
  <div class="content monospaced">
1667
- <pre>sudo sh -c 'echo "deb http://ppa.launchpad.net/brightbox/passenger/ubuntu hardy main" &gt; /etc/apt/sources.list.d/brightbox-passenger-nginx.list'
1699
+ <pre>sudo sh -c 'echo "deb http://ppa.launchpad.net/brightbox/passenger-experimental/ubuntu hardy main" &gt; /etc/apt/sources.list.d/brightbox-passenger-nginx.list'
1668
1700
  sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C3173AA6
1669
1701
  sudo apt-get update</pre>
1670
1702
  </div>
@@ -1889,16 +1921,29 @@ gpg --refresh-keys --keyserver keyserver.ubuntu.com</pre>
1889
1921
  </div>
1890
1922
  <div class="sect2">
1891
1923
  <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_customizing_the_compilation_process"></span><h3 data-comment-topic="customizing-the-compilation-process-1sds3od" data-anchor="_customizing_the_compilation_process">2.9. Customizing the compilation process</h3>
1924
+ <div class="paragraph"><p>The Phusion Passenger compilation process can be customized with environment variables. You can learn more about environment variables in <a href="#about_environment_variables">About environment variables</a>.</p></div>
1892
1925
  <div class="sect3">
1893
1926
  <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_setting_the_compiler"></span><h4 data-comment-topic="setting-the-compiler-1symq7h" data-anchor="_setting_the_compiler">2.9.1. Setting the compiler</h4>
1894
1927
  <div class="paragraph"><p>You can force the Phusion Passenger build system to use a specific C or C++ compiler by setting the <span class="monospaced">CC</span> and <span class="monospaced">CXX</span> environment variables. These may be set to any arbitrary shell commands.</p></div>
1895
1928
  <div class="paragraph"><p>For example, contributors who want to hack on Phusion Passenger may want to use Clang for faster compilation and <a href="http://ccache.samba.org/">ccache</a> for faster recompilation, and may want to enable more error-catching compilation flags:</p></div>
1896
1929
  <div class="listingblock">
1897
- <div class="content monospaced">
1898
- <pre>export CC='ccache clang -fcolor-diagnostics -Qunused-arguments -fcatch-undefined-behavior -ftrapv'
1899
- export CXX='ccache clang++ -fcolor-diagnostics -Qunused-arguments -fcatch-undefined-behavior -ftrapv'</pre>
1930
+ <div class="content">
1931
+ <!-- Generator: GNU source-highlight 2.11.1
1932
+ by Lorenzo Bettini
1933
+ http://www.lorenzobettini.it
1934
+ http://www.gnu.org/software/src-highlite -->
1935
+ <pre><tt><span style="font-weight: bold"><span style="color: #0000FF">export</span></span> <span style="color: #009900">CC</span><span style="color: #990000">=</span><span style="color: #FF0000">'ccache clang -fcolor-diagnostics -Qunused-arguments -fcatch-undefined-behavior -ftrapv'</span>
1936
+ <span style="font-weight: bold"><span style="color: #0000FF">export</span></span> <span style="color: #009900">CXX</span><span style="color: #990000">=</span><span style="color: #FF0000">'ccache clang++ -fcolor-diagnostics -Qunused-arguments -fcatch-undefined-behavior -ftrapv'</span></tt></pre>
1900
1937
  </div>
1901
1938
  </div>
1939
+ <div class="admonitionblock">
1940
+ <table><tr>
1941
+ <td class="icon">
1942
+ <img src="./images/icons/note.png" alt="Note">
1943
+ </td>
1944
+ <td class="content">If you run the installer with <span class="monospaced">sudo</span> then environment variables may not be passed properly. Learn more at <a href="#env_vars_and_sudo">Environment variables and sudo</a>.</td>
1945
+ </tr></table>
1946
+ </div>
1902
1947
  </div>
1903
1948
  <div class="sect3">
1904
1949
  <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_adding_additional_compiler_or_linker_flags"></span><h4 data-comment-topic="adding-additional-compiler-or-linker-flags-wzu0ey" data-anchor="_adding_additional_compiler_or_linker_flags">2.9.2. Adding additional compiler or linker flags</h4>
@@ -1953,11 +1998,19 @@ export CXX='ccache clang++ -fcolor-diagnostics -Qunused-arguments -fcatch-undefi
1953
1998
  </p>
1954
1999
  </dd>
1955
2000
  </dl></div>
2001
+ <div class="admonitionblock">
2002
+ <table><tr>
2003
+ <td class="icon">
2004
+ <img src="./images/icons/note.png" alt="Note">
2005
+ </td>
2006
+ <td class="content">If you run the installer with <span class="monospaced">sudo</span> then environment variables may not be passed properly. Learn more at <a href="#env_vars_and_sudo">Environment variables and sudo</a>.</td>
2007
+ </tr></table>
2008
+ </div>
1956
2009
  </div>
1957
2010
  <div class="sect3">
1958
- <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_forcing_location_of_certain_command_line_tools"></span><h4 data-comment-topic="forcing-location-of-certain-command-line-tools-1hym30u" data-anchor="_forcing_location_of_certain_command_line_tools">2.9.3. Forcing location of certain command line tools</h4>
2011
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_forcing_location_of_command_line_tools_and_dependencies"></span><h4 data-comment-topic="forcing-location-of-certain-command-line-tools-1hym30u" data-anchor="_forcing_location_of_command_line_tools_and_dependencies">2.9.3. Forcing location of command line tools and dependencies</h4>
1959
2012
  <div class="paragraph"><p>The Phusion Passenger build system attempts to autodetect many things by locating relevant helper tools. For example, to find out which compiler flags it should use for compiling Apache modules, it locates the <span class="monospaced">apxs2</span> command and queries it. To find out which compiler flags it should use for libcurl, it queries the <span class="monospaced">curl-config</span> command. These commands may not be in <span class="monospaced">$PATH</span>, or even when they are you may want to use a different one.</p></div>
1960
- <div class="paragraph"><p>You can often force the build to find certain command line tools at certain locations by using the following environment variables:</p></div>
2013
+ <div class="paragraph"><p>You can force the build to find certain command line tools at certain locations by using the following environment variables:</p></div>
1961
2014
  <div class="dlist"><dl>
1962
2015
  <dt class="hdlist1">
1963
2016
  <span class="monospaced">HTTPD</span>
@@ -1972,8 +2025,18 @@ export CXX='ccache clang++ -fcolor-diagnostics -Qunused-arguments -fcatch-undefi
1972
2025
  </dt>
1973
2026
  <dd>
1974
2027
  <p>
1975
- The location of the <span class="monospaced">apxs2</span> executable (the Apache module developer tool).
2028
+ The location of the <span class="monospaced">apxs2</span> executable (the Apache module developer tool). Only used by <span class="monospaced">passenger-install-apache2-module</span>.
1976
2029
  </p>
2030
+ <div class="paragraph"><p>This environment variable, together with <span class="monospaced">HTTPD</span>, are what you need to customize if you have multiple Apache installations on your system, or if your Apache is located in a non-standard location which Phusion Passenger cannot detect. By setting <span class="monospaced">APXS2</span> and <span class="monospaced">HTTP</span> to the right paths, you can force Phusion Passenger to be compiled against that specific Apache installation.</p></div>
2031
+ <div class="paragraph"><p>For example, if your Apache installation is located in <span class="monospaced">/opt/lamp/apache2</span>, then you can run the installer as follows:</p></div>
2032
+ <div class="listingblock">
2033
+ <div class="content monospaced">
2034
+ <pre>$ sudo bash
2035
+ # export HTTPD=/opt/lampp/apache2/bin/apache
2036
+ # export APXS2=/opt/lampp/apache2/bin/apxs
2037
+ # passenger-install-apache2-module</pre>
2038
+ </div>
2039
+ </div>
1977
2040
  </dd>
1978
2041
  <dt class="hdlist1">
1979
2042
  <span class="monospaced">APR_CONFIG</span>
@@ -2008,6 +2071,14 @@ export CXX='ccache clang++ -fcolor-diagnostics -Qunused-arguments -fcatch-undefi
2008
2071
  </p>
2009
2072
  </dd>
2010
2073
  </dl></div>
2074
+ <div class="admonitionblock">
2075
+ <table><tr>
2076
+ <td class="icon">
2077
+ <img src="./images/icons/note.png" alt="Note">
2078
+ </td>
2079
+ <td class="content">If you run the installer with <span class="monospaced">sudo</span> then environment variables may not be passed properly. Learn more at <a href="#env_vars_and_sudo">Environment variables and sudo</a>.</td>
2080
+ </tr></table>
2081
+ </div>
2011
2082
  </div>
2012
2083
  </div>
2013
2084
  <div class="sect2">
@@ -2109,7 +2180,7 @@ done this, you need to remove the Phusion Passenger files.</p></div>
2109
2180
  <div class="ulist"><ul>
2110
2181
  <li>
2111
2182
  <p>
2112
- If you installed Phusion Passenger via a Ruby gem, then run <span class="monospaced">gem uninstall passenger</span> (or, if you’re an <a href="https://www.phusionpassenger.com/enterprise">Phusion Passenger Enterprise</a> user, <span class="monospaced">gem uninstall passenger-enterprise-server</span>).
2183
+ If you installed Phusion Passenger via a Ruby gem, then run <span class="monospaced">gem uninstall passenger</span> (or, if you’re a <a href="https://www.phusionpassenger.com/enterprise">Phusion Passenger Enterprise</a> user, <span class="monospaced">gem uninstall passenger-enterprise-server</span>).
2113
2184
  You <a href="#is_ruby_home_or_system_wide_installed">might have to run this as root</a>.
2114
2185
  </p>
2115
2186
  </li>
@@ -2879,7 +2950,7 @@ this option as well. Please read
2879
2950
  <div class="paragraph"><p>This required option may only occur once, in the global server configuration.</p></div>
2880
2951
  </div>
2881
2952
  <div class="sect2">
2882
- <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="PassengerDefaultRuby"></span><h3 data-comment-topic="passengerdefaultruby-and-passengerruby-7zblp8" data-anchor="PassengerDefaultRuby">6.2. PassengerDefaultRuby and PassengerRuby</h3>
2953
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="PassengerDefaultRuby"></span><h3 data-comment-topic="passengerdefaultruby-and-passengerruby-7zblp8" data-anchor="PassengerDefaultRuby">6.2. PassengerDefaultRuby &lt;filename&gt;</h3>
2883
2954
  <div class="paragraph"><p><strong>Introduced in version 4.0.0.</strong></p></div>
2884
2955
  <div class="paragraph"><p>This option specifies the default Ruby interpreter to use for web apps as well as for all sorts of internal Phusion Passenger helper scripts, e.g. the one used by <a href="#PassengerPreStart">PassengerPreStart</a>. Please see <a href="#PassengerRuby">PassengerRuby</a> for more information, as well as how it relates to <a href="#PassengerRuby">PassengerRuby</a>.</p></div>
2885
2956
  <div class="paragraph"><p>This option may occur in the global server configuration. The default value is <em>ruby</em>, meaning that the Ruby interpreter will be looked up according to the <span class="monospaced">PATH</span> environment variable.</p></div>
@@ -3559,7 +3630,7 @@ In <em>.htaccess</em>, if <span class="monospaced">AllowOverride Options</span>
3559
3630
  The default value is <em>on</em>.</p></div>
3560
3631
  </div>
3561
3632
  <div class="sect3">
3562
- <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_passengeruser_lt_username_gt"></span><h4 data-comment-topic="passengeruser" data-anchor="_passengeruser_lt_username_gt">6.14.2. PassengerUser &lt;username&gt;</h4>
3633
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="PassengerUser"></span><h4 data-comment-topic="passengeruser" data-anchor="PassengerUser">6.14.2. PassengerUser &lt;username&gt;</h4>
3563
3634
  <div class="paragraph"><p>If <a href="#user_switching">user switching support</a> is enabled, then Phusion Passenger will
3564
3635
  by default run the web application as the owner of the file <em>config/environment.rb</em>
3565
3636
  (for Rails apps) or <em>config.ru</em> (for Rack apps). This option allows you to override
@@ -3586,7 +3657,7 @@ In a <span class="monospaced">&lt;Directory&gt;</span> or <span class="monospace
3586
3657
  <div class="paragraph"><p>In each place, it may be specified at most once.</p></div>
3587
3658
  </div>
3588
3659
  <div class="sect3">
3589
- <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_passengergroup_lt_group_name_gt"></span><h4 data-comment-topic="passengergroup" data-anchor="_passengergroup_lt_group_name_gt">6.14.3. PassengerGroup &lt;group name&gt;</h4>
3660
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="PassengerGroup"></span><h4 data-comment-topic="passengergroup" data-anchor="PassengerGroup">6.14.3. PassengerGroup &lt;group name&gt;</h4>
3590
3661
  <div class="paragraph"><p>If <a href="#user_switching">user switching support</a> is enabled, then Phusion Passenger will
3591
3662
  by default run the web application as the primary group of the owner of the file
3592
3663
  <em>config/environment.rb</em> (for Rails apps) or <em>config.ru</em> (for Rack apps). This option
@@ -3632,7 +3703,7 @@ The default value is the primary group of the user specifified by
3632
3703
  <a href="#PassengerDefaultUser">PassengerDefaultUser</a>.</p></div>
3633
3704
  </div>
3634
3705
  <div class="sect3">
3635
- <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_passengerfriendlyerrorpages_lt_on_off_gt"></span><h4 data-comment-topic="passengerfriendlyerrorpages" data-anchor="_passengerfriendlyerrorpages_lt_on_off_gt">6.14.6. PassengerFriendlyErrorPages &lt;on|off&gt;</h4>
3706
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="PassengerFriendlyErrorPages"></span><h4 data-comment-topic="passengerfriendlyerrorpages" data-anchor="PassengerFriendlyErrorPages">6.14.6. PassengerFriendlyErrorPages &lt;on|off&gt;</h4>
3636
3707
  <div class="paragraph"><p>Phusion Passenger can display friendly error pages whenever an application fails
3637
3708
  to start. This friendly error page presents the startup error message, some
3638
3709
  suggestions for solving the problem, and a backtrace. This feature is very useful
@@ -4080,6 +4151,17 @@ measure to avoid freezing applications.</p></div>
4080
4151
  </td>
4081
4152
  </tr></table>
4082
4153
  </div>
4154
+ <div class="admonitionblock">
4155
+ <table><tr>
4156
+ <td class="icon">
4157
+ <img src="./images/icons/note.png" alt="Note">
4158
+ </td>
4159
+ <td class="content">
4160
+ <div class="paragraph"><p>This option is currently only available for Ruby apps. It is not yet available
4161
+ for Python and Node.js.</p></div>
4162
+ </td>
4163
+ </tr></table>
4164
+ </div>
4083
4165
  </div>
4084
4166
  <div class="sect3">
4085
4167
  <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="PassengerMemoryLimit"></span><h4 data-comment-topic="passengermemorylimit-integer--18irza1" data-anchor="PassengerMemoryLimit">6.15.11. PassengerMemoryLimit &lt;integer&gt;</h4>
@@ -4623,7 +4705,7 @@ displaying maintenance.html will work fine even for URLs starting with "/users".
4623
4705
  <div class="sect2">
4624
4706
  <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_logging_and_debugging_options"></span><h3 data-comment-topic="logging-and-debugging-options-el2cuc" data-anchor="_logging_and_debugging_options">6.17. Logging and debugging options</h3>
4625
4707
  <div class="sect3">
4626
- <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_passengerloglevel_lt_integer_gt"></span><h4 data-comment-topic="passengerloglevel-integer--s3kbil" data-anchor="_passengerloglevel_lt_integer_gt">6.17.1. PassengerLogLevel &lt;integer&gt;</h4>
4708
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="PassengerLogLevel"></span><h4 data-comment-topic="passengerloglevel-integer--s3kbil" data-anchor="PassengerLogLevel">6.17.1. PassengerLogLevel &lt;integer&gt;</h4>
4627
4709
  <div class="paragraph"><p>This option allows one to specify how much information Phusion Passenger should
4628
4710
  write to the Apache error log file. A higher log level value means that more
4629
4711
  information will be logged.</p></div>
@@ -5670,51 +5752,199 @@ through the <em>X-Passenger-Connect-Password</em> HTTP header, like this:</p></d
5670
5752
  <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_tips"></span><h2 data-comment-topic="tips-19cwwf7" data-anchor="_tips">9. Tips</h2>
5671
5753
  <div class="sectionbody">
5672
5754
  <div class="sect2">
5673
- <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="user_switching"></span><h3 data-comment-topic="user-switching-security--8njx1x" data-anchor="user_switching">9.1. User switching (security)</h3>
5674
- <div class="paragraph"><p>There is a problem that plagues most PHP web hosts, namely the fact that all PHP
5755
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="user_switching"></span><h3 data-comment-topic="user-switching-security--8njx1x" data-anchor="user_switching">9.1. User Switching (security feature)</h3>
5756
+ <div class="paragraph"><p>Phusion Passenger supports automatic <em>user switching</em>: by default, it attempts to run applications as the "right" user, instead of running all applications as the same user.</p></div>
5757
+ <div class="paragraph"><p>To better understand the problem, let us consider the situation with PHP.
5758
+ There is a problem that plagues most PHP web hosts, namely the fact that all PHP
5675
5759
  applications are run in the same user context as the web server. So for
5676
5760
  example, Joe’s PHP application will be able to read Jane’s PHP application’s
5677
5761
  passwords. This is obviously undesirable on many servers.</p></div>
5678
- <div class="paragraph"><p>Phusion Passenger solves this problem by implementing <em>user switching</em>. A Rails
5679
- application is started as the owner of the file <em>config/environment.rb</em>,
5680
- and a Rack application is started as the owner of the file <em>config.ru</em>.
5681
- So if <em>/home/webapps/foo/config/environment.rb</em> is owned by <em>joe</em>, then Phusion
5682
- Passenger will launch the corresponding application as <em>joe</em> as well.</p></div>
5683
- <div class="paragraph"><p>This behavior is the default, and you don’t need to configure anything. But
5684
- there are things that you should keep in mind:</p></div>
5762
+ <div class="paragraph"><p>Phusion Passenger’s <em>user switching</em> feature solves this problem. Applications are
5763
+ run as the owner of their "startup file". For Ruby apps, the startup file is
5764
+ <span class="monospaced">config.ru</span> (Rack and Rails &gt;= 3) or <span class="monospaced">config/environment.rb</span> (Rails 1 and 2). For
5765
+ Python apps, the startup file is <span class="monospaced">passenger_wsgi.py</span>. So suppose that <span class="monospaced">config.ru</span>
5766
+ is owned by user <em>joe</em>, then Phusion Passenger will spawn the corresponding
5767
+ application as <em>joe</em> as well. The exact rules are a little bit more complicated,
5768
+ and they’re explained further down in this section.</p></div>
5769
+ <div class="sect3">
5770
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_requirements"></span><h4 data-comment-topic="requirements-yxvtxo" data-anchor="_requirements">9.1.1. Requirements</h4>
5771
+ <div class="paragraph"><p>User switching is only enabled when all of the following conditions are met:</p></div>
5772
+ <div class="ulist"><ul>
5773
+ <li>
5774
+ <p>
5775
+ When not using <a href="#flying_passenger">Flying Passenger</a> (this is probably the case):
5776
+ </p>
5777
+ <div class="ulist"><ul>
5778
+ <li>
5779
+ <p>
5780
+ The
5781
+ <a href="#PassengerUserSwitching">PassengerUserSwitching</a>
5782
+ option must be enabled.
5783
+ </p>
5784
+ </li>
5785
+ <li>
5786
+ <p>
5787
+ The web server’s control process must have root privileges. This is the case on most installations.
5788
+ </p>
5789
+ </li>
5790
+ </ul></div>
5791
+ </li>
5792
+ <li>
5793
+ <p>
5794
+ When using <a href="#flying_passenger">Flying Passenger</a>:
5795
+ </p>
5685
5796
  <div class="ulist"><ul>
5686
5797
  <li>
5687
5798
  <p>
5688
- The owner of <em>environment.rb</em>/<em>config.ru</em> must have read access to the application’s
5689
- root directory, and read/write access to the application’s <em>logs</em> directory.
5799
+ The Flying Passenger daemon must be run with root privileges.
5690
5800
  </p>
5691
5801
  </li>
5802
+ </ul></div>
5803
+ </li>
5804
+ </ul></div>
5805
+ </div>
5806
+ <div class="sect3">
5807
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_effects"></span><h4 data-comment-topic="effects-1lko7vo" data-anchor="_effects">9.1.2. Effects</h4>
5808
+ <div class="paragraph"><p>When not using Flying Passenger, the following table illustrates the effect for different combinations of the requirements.</p></div>
5809
+ <table class="tableblock frame-all grid-all" style="
5810
+ width:100%;
5811
+ ">
5812
+ <col style="width:33%;">
5813
+ <col style="width:33%;">
5814
+ <col style="width:33%;">
5815
+ <tbody>
5816
+ <tr>
5817
+ <td class="tableblock halign-left valign-top"><p class="tableblock"></p></td>
5818
+ <td class="tableblock halign-left valign-top"><p class="tableblock"><strong>PassengerUserSwitching on</strong></p></td>
5819
+ <td class="tableblock halign-left valign-top"><p class="tableblock"><strong>PassengerUserSwitching off</strong></p></td>
5820
+ </tr>
5821
+ <tr>
5822
+ <td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Web server has root privileges</strong></p></td>
5823
+ <td class="tableblock halign-left valign-top"><p class="tableblock">User switching enabled.</p></td>
5824
+ <td class="tableblock halign-left valign-top"><p class="tableblock">User switching disabled. Apps are run as
5825
+ <a href="#PassengerDefaultUser">PassengerDefaultUser</a> and
5826
+ <a href="#PassengerDefaultGroup">PassengerDefaultGroup</a>.</p></td>
5827
+ </tr>
5828
+ <tr>
5829
+ <td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Web server has no root privileges</strong></p></td>
5830
+ <td class="tableblock halign-left valign-top"><p class="tableblock">User switching disabled. Apps are run as the web server’s user.</p></td>
5831
+ <td class="tableblock halign-left valign-top"><p class="tableblock">User switching disabled. Apps are run as the web server’s user.</p></td>
5832
+ </tr>
5833
+ </tbody>
5834
+ </table>
5835
+ <div class="paragraph"><p>When using Flying Passenger, the effect is as follows:</p></div>
5836
+ <table class="tableblock frame-all grid-all" style="
5837
+ width:100%;
5838
+ ">
5839
+ <col style="width:50%;">
5840
+ <col style="width:50%;">
5841
+ <tbody>
5842
+ <tr>
5843
+ <td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Daemon run with root privileges</strong></p></td>
5844
+ <td class="tableblock halign-left valign-top"><p class="tableblock">User switching enabled.</p></td>
5845
+ </tr>
5846
+ <tr>
5847
+ <td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Daemon run without root privileges</strong></p></td>
5848
+ <td class="tableblock halign-left valign-top"><p class="tableblock">User switching disabled. Apps are run as the daemon’s user.</p></td>
5849
+ </tr>
5850
+ </tbody>
5851
+ </table>
5852
+ <div class="paragraph"><p>When user switching is enabled, the following rules are followed to determine what user an application should be run as. The first matching rule is the rule that will be followed.</p></div>
5853
+ <div class="olist arabic"><ol class="arabic">
5692
5854
  <li>
5693
5855
  <p>
5694
- This feature is only available if the web server is started by <em>root</em>. This is the
5695
- case on most installations.
5856
+ If
5857
+ <a href="#PassengerUser">PassengerUser</a> or
5858
+ <a href="#PassengerGroup">PassengerGroup</a>
5859
+ are set, then the application will be run as the specified user/group. Thus, these options are a good way to override user switching settings.
5696
5860
  </p>
5697
5861
  </li>
5698
5862
  <li>
5699
5863
  <p>
5700
- Under no circumstances will applications be run as <em>root</em>. If
5701
- <em>environment.rb</em>/<em>config.ru</em> is owned as root or by an unknown user, then the
5702
- Rails/Rack application will run as the user specified by
5864
+ If the startup file is owned by root or an unknown user, then the application will run as the user specified by
5703
5865
  <a href="#PassengerDefaultUser">PassengerDefaultUser</a> and
5704
5866
  <a href="#PassengerDefaultGroup">PassengerDefaultGroup</a>.
5705
5867
  </p>
5706
5868
  </li>
5869
+ <li>
5870
+ <p>
5871
+ Otherwise, the application is run as the owner of the startup file.
5872
+ </p>
5873
+ </li>
5874
+ </ol></div>
5875
+ </div>
5876
+ <div class="sect3">
5877
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_caveats_amp_troubleshooting"></span><h4 data-comment-topic="caveats-troubleshooting-161hgge" data-anchor="_caveats_amp_troubleshooting">9.1.3. Caveats &amp; troubleshooting</h4>
5878
+ <div class="paragraph"><p>If your application regularly encounters permission errors or fails to find certain files, then this is an indication that your application is started as a user that you did not intent it to be run as. Other symptoms include:</p></div>
5879
+ <div class="ulist"><ul>
5880
+ <li>
5881
+ <p>
5882
+ The application fails to start because Bundler complains that it cannot find gems. This probably indicates that Bundler does not have read access to the directory that contains Bundler-installed gems.
5883
+ </p>
5884
+ </li>
5885
+ <li>
5886
+ <p>
5887
+ The application fails to start and its error message mentions the path <em>/nonexistent</em>. This probably indicates that your application is started as the <em>nobody</em> user. This is because on many systems, the <em>nobody</em> user’s home directory is <em>/nonexistent</em>.
5888
+ </p>
5889
+ </li>
5707
5890
  </ul></div>
5708
- <div class="paragraph"><p>User switching can be disabled with the
5709
- <a href="#PassengerUserSwitching">PassengerUserSwitching</a>
5710
- option.</p></div>
5891
+ <div class="paragraph"><p>To check whether it is indeed the case that your application is started as a different user than you intended to, see <a href="#finding_out_app_user">Finding out what user an application is running as</a>.</p></div>
5892
+ <div class="paragraph"><p>The most likely reason why your application is started as <em>nobody</em> is probably because your startup file is owned by <em>root</em>, by <em>nobody</em> or by an unknown user. To fix this, change the owner of the startup file to the owner that you want to run the application as.</p></div>
5893
+ <div class="paragraph"><p>Whatever user your application runs as, it must have read access to the <a href="#application_root">application root</a>, and read/write access to the application’s <em>logs</em> directory.</p></div>
5894
+ </div>
5895
+ <div class="sect3">
5896
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="finding_out_app_user"></span><h4 data-comment-topic="finding-out-what-user-an-application-is-running-as-7uwrol" data-anchor="finding_out_app_user">9.1.4. Finding out what user an application is running as</h4>
5897
+ <div class="paragraph"><p>To find our what user an application is started as, first access its URL in your browser so that Phusion Passenger starts the application. For example:</p></div>
5898
+ <div class="listingblock">
5899
+ <div class="content monospaced">
5900
+ <pre>http://www.example.local/</pre>
5901
+ </div>
5902
+ </div>
5903
+ <div class="paragraph"><p>The application will now either successfully start or fail to start. If it fails to start then you will see an error page that tells you what user the application was being started as. If you do not see the error page in the browser then set
5904
+ <a href="#PassengerFriendlyErrorPages">PassengerFriendlyErrorPages</a>
5905
+ on.</p></div>
5906
+ <div class="paragraph"><p>If the application successfully started, then run <span class="monospaced">passenger-status</span> to find the process’s PID:</p></div>
5907
+ <div class="listingblock">
5908
+ <div class="content monospaced">
5909
+ <pre>.---------- General information -----------
5910
+ Max pool size : 6
5911
+ Processes : 1
5912
+ Requests in top-level queue : 0
5913
+
5914
+ .---------- Application groups -----------
5915
+ /webapps/example.local#default:
5916
+ App root: /webapps/example.local
5917
+ Requests in queue: 0
5918
+ * PID: 16915 Sessions: 0 Processed: 1 Uptime: 2s
5919
+ CPU: 0% Memory : 9M Last used: 2s ago</pre>
5920
+ </div>
5921
+ </div>
5922
+ <div class="paragraph"><p>In the above example we see that the PID is 16915. Next, use <em>ps</em> to find out the user that it is running as:</p></div>
5923
+ <div class="listingblock">
5924
+ <div class="content monospaced">
5925
+ <pre># ps -o pid,user,comm -p 16915
5926
+ PID USER COMM
5927
+ 16915 phusion Passenger RackApp: /webapps/example.local</pre>
5928
+ </div>
5929
+ </div>
5930
+ <div class="paragraph"><p>As you can see, the application in this example is being run as user <em>phusion</em>.</p></div>
5931
+ </div>
5711
5932
  </div>
5712
5933
  <div class="sect2">
5713
- <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="reducing_memory_usage"></span><h3 data-comment-topic="reducing-memory-consumption-of-ruby-on-rails-applications-by-33--1ubxnq0" data-anchor="reducing_memory_usage">9.2. Reducing memory consumption of Ruby on Rails applications by 33%</h3>
5714
- <div class="paragraph"><p>Is it possible to reduce memory consumption of your Rails applications by 33% on average,
5715
- by using <a href="http://www.rubyenterpriseedition.com/">Ruby Enterprise Edition</a>.
5716
- Please visit the website for details.</p></div>
5717
- <div class="paragraph"><p>Note that this feature does not apply to Rack applications.</p></div>
5934
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="reducing_memory_usage"></span><h3 data-comment-topic="reducing-memory-consumption-of-ruby-on-rails-applications-by-33--1ubxnq0" data-anchor="reducing_memory_usage">9.2. Copy-on-write memory support (reducing memory consumption of Ruby applications)</h3>
5935
+ <div class="paragraph"><p>Phusion Passenger automatically leverages operating system virtual memory copy-on-write features in order to reduce the memory usage of Ruby applications. Experience has shown that this reduces memory usage by 33% on average. For this mechanism to work, a Ruby interpreter with a copy-on-write friendly garbage collector is required. The following Ruby interpreters have copy-on-write friendly garbage collectors:</p></div>
5936
+ <div class="ulist"><ul>
5937
+ <li>
5938
+ <p>
5939
+ MRI Ruby &gt;= 2.0. Versions prior to 2.0 did not have a copy-on-write friendly garbage collector.
5940
+ </p>
5941
+ </li>
5942
+ <li>
5943
+ <p>
5944
+ <a href="http://www.rubyenterpriseedition.com/">Ruby Enterprise Edition</a>, which was Phusion’s branch of MRI Ruby 1.8 with a copy-on-write friendly garbage collector and other enhancement. It has reached End-Of-Life as of 2012, but remains available for legacy systems.
5945
+ </p>
5946
+ </li>
5947
+ </ul></div>
5718
5948
  </div>
5719
5949
  <div class="sect2">
5720
5950
  <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="capistrano"></span><h3 data-comment-topic="capistrano-recipe-syzgo7" data-anchor="capistrano">9.3. Capistrano recipe</h3>
@@ -5754,7 +5984,9 @@ end</pre>
5754
5984
  <div class="sect2">
5755
5985
  <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="bundler_support"></span><h3 data-comment-topic="bundler-support-cf72ih" data-anchor="bundler_support">9.4. Bundler support</h3>
5756
5986
  <div class="paragraph"><p>Phusion Passenger has automatic support for <a href="http://gembundler.com/git.html">Bundler</a>.
5757
- It works as follows:</p></div>
5987
+ The support consists of loading your application under the environment defined by your
5988
+ Gemfile. In other words, Phusion Passenger loads your application as if <em>bundle exec</em> was used.</p></div>
5989
+ <div class="paragraph"><p>The Bundler support works as follows:</p></div>
5758
5990
  <div class="ulist"><ul>
5759
5991
  <li>
5760
5992
  <p>
@@ -5779,10 +6011,22 @@ have any negative effects.</p></div>
5779
6011
  <div class="paragraph"><p>Phusion Passenger assumes that you’re using Bundler &gt;= 0.9.5. If you don’t want Phusion
5780
6012
  Passenger to run its Bundler support code, e.g. because you need to use an older version
5781
6013
  of Bundler with an incompatible API or because you use a system other than Bundler, then
5782
- you can override Phusion Passenger’s Bundler support code by creating a file
6014
+ you can override Phusion Passenger’s Bundler support code by creating an empty file
5783
6015
  <em>config/setup_load_paths.rb</em>. If this file exists then it will be required before loading
5784
6016
  the application startup file. In this file you can do whatever you need to setup Bundler
5785
6017
  or a similar system.</p></div>
6018
+ <div class="sect3">
6019
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="add_passenger_to_gemfile"></span><h4 data-comment-topic="does-phusion-passenger-itself-need-to-be-added-to-the-gemfile--17whimp" data-anchor="add_passenger_to_gemfile">9.4.1. Does Phusion Passenger itself need to be added to the Gemfile?</h4>
6020
+ <div class="paragraph"><p>It is never necessary to add Phusion Passenger to the application’s Gemfile. In case of Phusion Passenger Standalone, it is not necessary to execute the <span class="monospaced">passenger</span> command through <span class="monospaced">bundle exec</span>. The reason for this is because Phusion Passenger automatically loads the Gemfile environment. Most other Ruby application servers do not automatically load the Gemfile environment, which is why they must be added to the Gemfile and be executed with <span class="monospaced">bundle exec</span>.</p></div>
6021
+ <div class="paragraph"><p>Even when your application uses any of the Phusion Passenger APIs, you still do not need to add Phusion Passenger to the Gemfile. The only thing you need to do is to put Phusion Passenger API calls inside <span class="monospaced">if</span> blocks that check whether Phusion Passenger is active, by checking whether the <span class="monospaced">PhusionPassenger</span> namespace is defined:</p></div>
6022
+ <div class="listingblock">
6023
+ <div class="content monospaced">
6024
+ <pre><strong>if</strong> defined?(PhusionPassenger)
6025
+ ...
6026
+ <strong>end</strong></pre>
6027
+ </div>
6028
+ </div>
6029
+ </div>
5786
6030
  </div>
5787
6031
  <div class="sect2">
5788
6032
  <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_installing_multiple_ruby_on_rails_versions"></span><h3 data-comment-topic="installing-multiple-ruby-on-rails-versions-mi5j14" data-anchor="_installing_multiple_ruby_on_rails_versions">9.5. Installing multiple Ruby on Rails versions</h3>
@@ -5894,7 +6138,7 @@ You can actually perform out-of-band work when you receive a <span class="monosp
5894
6138
  </li>
5895
6139
  </ol></div>
5896
6140
  <div class="paragraph"><p>Note that even though you can request out-of-band work, there’s no guarantee that Phusion Passenger will send an <span class="monospaced">oob_work</span> event in a timely manner, if at all. It is also possible that Phusion Passenger sends an <span class="monospaced">oob_work</span> event without you ever having requested one. This latter could for example happen if the OOB work is administrator-initiated. Do not make any assumptions in your code.</p></div>
5897
- <div class="paragraph"><p>Here’s an example which implements out-of-band garbage collection using the Out-of-Band framework:</p></div>
6141
+ <div class="paragraph"><p>Here’s an example which implements out-of-band garbage collection using the Out-of-Band framework. This example code doesn’t do anything when the code is not being run in Phusion Passenger, thanks to the <span class="monospaced">if</span> block.</p></div>
5898
6142
  <div class="listingblock">
5899
6143
  <div class="content">
5900
6144
  <!-- Generator: GNU source-highlight 2.11.1
@@ -5906,27 +6150,32 @@ http://www.gnu.org/software/src-highlite -->
5906
6150
  response<span style="color: #990000">.</span>headers<span style="color: #990000">[</span><span style="color: #FF0000">"X-Passenger-Request-OOB-Work"</span><span style="color: #990000">]</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"true"</span>
5907
6151
 
5908
6152
  <span style="font-style: italic"><span style="color: #9A1900"># Somewhere during application initialization:</span></span>
5909
- PhusionPassenger<span style="color: #990000">.</span>on_event<span style="color: #990000">(:</span>oob_work<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">do</span></span>
5910
- <span style="font-style: italic"><span style="color: #9A1900"># Phusion Passenger has told us that we're ready to perform OOB work.</span></span>
5911
- t0 <span style="color: #990000">=</span> Time<span style="color: #990000">.</span>now
5912
- GC<span style="color: #990000">.</span>start
5913
- Rails<span style="color: #990000">.</span>logger<span style="color: #990000">.</span>info <span style="color: #FF0000">"Out-Of-Bound GC finished in #{Time.now - t0} sec"</span>
6153
+ <span style="font-weight: bold"><span style="color: #0000FF">if</span></span> <span style="font-weight: bold"><span style="color: #0000FF">defined</span></span><span style="color: #990000">?(</span>PhusionPassenger<span style="color: #990000">)</span>
6154
+ PhusionPassenger<span style="color: #990000">.</span>on_event<span style="color: #990000">(:</span>oob_work<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">do</span></span>
6155
+ <span style="font-style: italic"><span style="color: #9A1900"># Phusion Passenger has told us that we're ready to perform OOB work.</span></span>
6156
+ t0 <span style="color: #990000">=</span> Time<span style="color: #990000">.</span>now
6157
+ GC<span style="color: #990000">.</span>start
6158
+ Rails<span style="color: #990000">.</span>logger<span style="color: #990000">.</span>info <span style="color: #FF0000">"Out-Of-Bound GC finished in #{Time.now - t0} sec"</span>
6159
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
5914
6160
  <span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre>
5915
6161
  </div>
5916
6162
  </div>
5917
- <div class="paragraph"><p>For your convenience, Phusion Passenger provides a Rack middleware for out-of-band garbage collection. Add this to your <span class="monospaced">config.ru</span>:</p></div>
6163
+ <div class="paragraph"><p>For your convenience, Phusion Passenger provides a Rack middleware for out-of-band garbage collection. Add the following to your <span class="monospaced">config.ru</span>. Likewise, this example code doesn’t do anything when the code is not being run in Phusion Passenger, thanks to the <span class="monospaced">if</span> block.</p></div>
5918
6164
  <div class="listingblock">
5919
6165
  <div class="content">
5920
6166
  <!-- Generator: GNU source-highlight 2.11.1
5921
6167
  by Lorenzo Bettini
5922
6168
  http://www.lorenzobettini.it
5923
6169
  http://www.gnu.org/software/src-highlite -->
5924
- <pre><tt><span style="font-weight: bold"><span style="color: #000080">require</span></span> <span style="color: #FF0000">'phusion_passenger/rack/out_of_band_gc'</span>
6170
+ <pre><tt><span style="font-weight: bold"><span style="color: #0000FF">if</span></span> <span style="font-weight: bold"><span style="color: #0000FF">defined</span></span><span style="color: #990000">?(</span>PhusionPassenger<span style="color: #990000">)</span>
6171
+ <span style="font-weight: bold"><span style="color: #000080">require</span></span> <span style="color: #FF0000">'phusion_passenger/rack/out_of_band_gc'</span>
5925
6172
 
5926
- <span style="font-style: italic"><span style="color: #9A1900"># Trigger out-of-band GC every 5 requests.</span></span>
5927
- use PhusionPassenger<span style="color: #990000">::</span>Rack<span style="color: #990000">::</span>OutOfBandGc<span style="color: #990000">,</span> <span style="color: #993399">5</span></tt></pre>
6173
+ <span style="font-style: italic"><span style="color: #9A1900"># Trigger out-of-band GC every 5 requests.</span></span>
6174
+ use PhusionPassenger<span style="color: #990000">::</span>Rack<span style="color: #990000">::</span>OutOfBandGc<span style="color: #990000">,</span> <span style="color: #993399">5</span>
6175
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre>
5928
6176
  </div>
5929
6177
  </div>
6178
+ <div class="paragraph"><p>It should be noted that, although the application uses the Phusion Passenger API, it is <a href="#add_passenger_to_gemfile"><strong>not</strong> necessary to add Phusion Passenger to the Gemfile</a>.</p></div>
5930
6179
  <div class="paragraph"><p>References:</p></div>
5931
6180
  <div class="ulist"><ul>
5932
6181
  <li>
@@ -5937,12 +6186,223 @@ use PhusionPassenger<span style="color: #990000">::</span>Rack<span style="color
5937
6186
  </ul></div>
5938
6187
  </div>
5939
6188
  <div class="sect2">
5940
- <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_x_sendfile_support"></span><h3 data-comment-topic="x-sendfile-support-1cgyykw" data-anchor="_x_sendfile_support">9.9. X-Sendfile support</h3>
6189
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="flying_passenger"></span><h3 data-comment-topic="flying-passenger-q916f7" data-anchor="flying_passenger">9.9. Flying Passenger</h3>
6190
+ <div class="paragraph"><p><strong>This feature is only available in <a href="https://www.phusionpassenger.com/enterprise">Phusion Passenger Enterprise</a>. It was introduced in version 4.0.6. <a href="https://www.phusionpassenger.com/download">Buy Phusion Passenger Enterprise here.</a></strong></p></div>
6191
+ <div class="paragraph"><p>Flying Passenger allows one to decouple Phusion Passenger’s life time from the web server’s life time, so that the web server can be independently restarted from Phusion Passenger, and from any of the application processes served by Phusion Passenger.</p></div>
6192
+ <div class="paragraph"><p>Normally, Phusion Passenger starts together with the web server, and shuts down together with the web server. The advantages of this default behavior is that it makes Phusion Passenger easy to administer: one only has to deal with the web server process and can expect all relevant processes to be cleaned up after a web server shut down. However this also brings about a disadvantage: every time one restarts the web server (e.g. to make a minor configuration change), Phusion Passenger and all its application processes also get restarted.</p></div>
6193
+ <div class="paragraph"><p>This problem is solved by <em>Flying Passenger</em>, which is an advanced mode of operation in Phusion Passenger that allows the web server to be indepedently restarted from Phusion Passenger. When this mode is enabled:</p></div>
6194
+ <div class="ulist"><ul>
6195
+ <li>
6196
+ <p>
6197
+ One must start Phusion Passenger separately from the web server, namely by starting the Flying Passenger daemon. This daemon must - to an extent - be separately configured and managed from the web server.
6198
+ </p>
6199
+ </li>
6200
+ <li>
6201
+ <p>
6202
+ The web server must be configured to forward requests to the Flying Passenger daemon.
6203
+ </p>
6204
+ </li>
6205
+ <li>
6206
+ <p>
6207
+ You should beware of the <a href="#flying_passenger_caveats">caveats and limitations</a>.
6208
+ </p>
6209
+ </li>
6210
+ </ul></div>
6211
+ <div class="sect3">
6212
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_requirements_2"></span><h4 data-comment-topic="requirements-1ntkin3" data-anchor="_requirements_2">9.9.1. Requirements</h4>
6213
+ <div class="paragraph"><p>At this time, this feature is <strong>only available in the Enterprise version of Phusion Passenger for Nginx</strong>. You must have Phusion Passenger for Nginx properly installed.</p></div>
6214
+ </div>
6215
+ <div class="sect3">
6216
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_basic_usage"></span><h4 data-comment-topic="basic-usage-joifsk" data-anchor="_basic_usage">9.9.2. Basic usage</h4>
6217
+ <div class="paragraph"><p>Start the Flying Passenger daemon by invoking the <span class="monospaced">flying-passenger</span> command. The only required option is <span class="monospaced">--socket-file</span>. Depending on whether you wish to enable <a href="#user_switching">User Switching</a>, you have to start <span class="monospaced">flying-passenger</span> with root privileges or not.</p></div>
6218
+ <div class="listingblock">
6219
+ <div class="content monospaced">
6220
+ <pre>$ sudo flying-passenger --socket-file=/var/run/flying-passenger.sock
6221
+ I, [2013-06-14T09:10:13.095339 #77179] INFO -- : Welcome to Flying Passenger 4.1.0
6222
+ I, [2013-06-14T09:10:13.095339 #77179] INFO -- : Starting PassengerWatchdog...
6223
+ I, [2013-06-14T09:10:13.097036 #77179] INFO -- : PassengerWatchdog started on PID 77181
6224
+ ...
6225
+ I, [2013-06-14T09:10:13.129017 #77179] INFO -- : PassengerWatchdog initialized properly
6226
+ I, [2013-06-14T09:10:13.129127 #77179] INFO -- : Flying Passenger up and listening on /var/run/flying-passenger.sock!</pre>
6227
+ </div>
6228
+ </div>
6229
+ <div class="paragraph"><p>Now configure Phusion Passenger for Nginx to make use of the Flying Passenger daemon, by setting the <span class="monospaced">passenger_fly_with</span> option to the socket filename:</p></div>
6230
+ <div class="listingblock">
6231
+ <div class="content monospaced">
6232
+ <pre>http {
6233
+ ...
6234
+ passenger_fly_with /var/run/flying-passenger.sock;
6235
+ ...
6236
+ }</pre>
6237
+ </div>
6238
+ </div>
6239
+ <div class="paragraph"><p>After (re)starting Nginx, Nginx + Flying Passenger is fully operational:</p></div>
6240
+ <div class="listingblock">
6241
+ <div class="content monospaced">
6242
+ <pre>$ sudo /path-to/nginx</pre>
6243
+ </div>
6244
+ </div>
6245
+ <div class="paragraph"><p>You can test it by adding a virtual host for a web app:</p></div>
6246
+ <div class="listingblock">
6247
+ <div class="content monospaced">
6248
+ <pre>http {
6249
+ ...
6250
+
6251
+ server {
6252
+ listen 80;
6253
+ server_name www.foo.local;
6254
+ root /webapps/foo/public;
6255
+ passenger_enabled on;
6256
+ }
6257
+ }</pre>
6258
+ </div>
6259
+ </div>
6260
+ <div class="paragraph"><p>Verify that it works by making an HTTP request to it:</p></div>
6261
+ <div class="listingblock">
6262
+ <div class="content monospaced">
6263
+ <pre>$ curl http://www.foo.local/</pre>
6264
+ </div>
6265
+ </div>
6266
+ <div class="paragraph"><p>Now let’s verify that restarting the web server does not restart the just-spawned application process. Run <span class="monospaced">passenger-status</span> to obtain the PID of the application process:</p></div>
6267
+ <div class="listingblock">
6268
+ <div class="content monospaced">
6269
+ <pre>$ sudo passenger-status
6270
+ Version: 4.1.0
6271
+ Date : 2013-06-14 09:21:51 -0400
6272
+ .---------- General information -----------
6273
+ Max pool size : 6
6274
+ Processes : 1
6275
+ Requests in top-level queue : 0
6276
+
6277
+ .---------- Application groups -----------
6278
+ /webapps/foo#default:
6279
+ App root: /webapps/foo
6280
+ Requests in queue: 0
6281
+ * PID: 77283 Sessions: 0 Processed: 1 Uptime: 2s
6282
+ CPU: 1% Memory : 8M Last used: 2s ago</pre>
6283
+ </div>
6284
+ </div>
6285
+ <div class="paragraph"><p>As you can see, the PID of the application process is <strong>77283</strong>. Now let’s see what happens if we restart Nginx:</p></div>
6286
+ <div class="listingblock">
6287
+ <div class="content monospaced">
6288
+ <pre>$ sudo /path-to/nginx -s stop
6289
+ $ sudo /path-to/nginx
6290
+ $ sudo passenger-status</pre>
6291
+ </div>
6292
+ </div>
6293
+ <div class="paragraph"><p>The application process should remain there, unchanged:</p></div>
6294
+ <div class="listingblock">
6295
+ <div class="content monospaced">
6296
+ <pre>$ sudo passenger-status
6297
+ Version: 4.1.0
6298
+ Date : 2013-06-14 09:21:51 -0400
6299
+ .---------- General information -----------
6300
+ Max pool size : 6
6301
+ Processes : 1
6302
+ Requests in top-level queue : 0
6303
+
6304
+ .---------- Application groups -----------
6305
+ /webapps/foo#default:
6306
+ App root: /webapps/foo
6307
+ Requests in queue: 0
6308
+ * PID: 77283 Sessions: 0 Processed: 1 Uptime: 18s
6309
+ CPU: 1% Memory : 8M Last used: 18s ago</pre>
6310
+ </div>
6311
+ </div>
6312
+ </div>
6313
+ <div class="sect3">
6314
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="configuring_flying_passenger"></span><h4 data-comment-topic="configuring-flying-passenger-1v35vgg" data-anchor="configuring_flying_passenger">9.9.3. Configuring Flying Passenger</h4>
6315
+ <div class="paragraph"><p>Flying Passenger gets <strong>some</strong> configuration from the web server, but not all. In particular, most web server directives that are only valid in the <span class="monospaced">http</span> context, e.g. <a href="#PassengerLogLevel">passenger_log_level</a>, have no effect when using Flying Passenger. Instead, you are supposed to pass these configuration directives through command line options to the Flying Passenger daemon. Configuration directives that have no effect on Flying Passenger are documented as such. You can assume that configuration directives that are not documented as such, work fine on Flying Passenger.</p></div>
6316
+ <div class="paragraph"><p>For example, to achieve the same effect as setting passenger_log_level to 2, run the Flying Passenger daemon as follows:</p></div>
6317
+ <div class="listingblock">
6318
+ <div class="content monospaced">
6319
+ <pre>$ sudo flying-passenger --socket-file=/var/run/flying-passenger.sock --log-level=2</pre>
6320
+ </div>
6321
+ </div>
6322
+ <div class="paragraph"><p>Currently, not all configuration directives have a Flying Passenger equivalent. Run the following command to see an overview of available options:</p></div>
6323
+ <div class="listingblock">
6324
+ <div class="content monospaced">
6325
+ <pre>$ flying-passenger --help</pre>
6326
+ </div>
6327
+ </div>
6328
+ </div>
6329
+ <div class="sect3">
6330
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_managing_the_flying_passenger_daemon"></span><h4 data-comment-topic="managing-the-flying-passenger-daemon-1bng2bu" data-anchor="_managing_the_flying_passenger_daemon">9.9.4. Managing the Flying Passenger daemon</h4>
6331
+ <div class="paragraph"><p>The Flying Passenger daemon runs in the foreground by default. This is undesirable on server environments. You can make it go into the background by passing <span class="monospaced">--daemonize</span>, <span class="monospaced">--log-file</span> and <span class="monospaced">--pid-file</span>:</p></div>
6332
+ <div class="listingblock">
6333
+ <div class="content monospaced">
6334
+ <pre>$ sudo flying-passenger --socket-file=/var/run/flying-passenger.sock \
6335
+ --daemonize --log-file=/var/log/flying-passenger.log \
6336
+ --pid-file=/var/run/flying-passenger.pid</pre>
6337
+ </div>
6338
+ </div>
6339
+ <div class="paragraph"><p>You can shut down a Flying Passenger daemon by sending SIGINT or SIGTERM to it:</p></div>
6340
+ <div class="listingblock">
6341
+ <div class="content monospaced">
6342
+ <pre>$ kill `cat /var/run/flying-passenger.pid`</pre>
6343
+ </div>
6344
+ </div>
6345
+ <div class="paragraph"><p>We recommend using <a href="http://cr.yp.to/daemontools.html">daemontools</a> or <a href="http://smarden.org/runit/">runit</a> for managing the Flying Passenger daemon. These tools will allow automatically starting the Flying Passenger daemon at boot, and will automatically restart the daemon if it crashes. You can create and enable a daemontools/runit service as folows:</p></div>
6346
+ <div class="listingblock">
6347
+ <div class="content monospaced">
6348
+ <pre>$ sudo mkdir /etc/service/flying-passenger
6349
+ $ sudo nano /etc/service/flying-passenger/run
6350
+ #!/bin/sh
6351
+ exec /path-to/flying-passenger \
6352
+ --socket-file=/var/run/flying-passenger.sock \
6353
+ --log-file=/var/log/flying-passenger.log \
6354
+ --pid-file=/var/run/flying-passenger.pid</pre>
6355
+ </div>
6356
+ </div>
6357
+ <div class="paragraph"><p>Immediately after creating the <span class="monospaced">run</span> file, daemontools/runit automatically runs it to start the daemon. Note that the location (<span class="monospaced">/etc/service</span>) depends on the OS or Linux distros. Sometimes it’s <span class="monospaced">/service</span>. Also note that we start the Flying Passenger daemon without <span class="monospaced">--daemonize</span>.</p></div>
6358
+ <div class="paragraph"><p>To shut down a daemontools/runit-managed daemon, you need to use <span class="monospaced">svc -d /etc/service/flying-passenger</span> (daemontools) or <span class="monospaced">sv stop /etc/service/flying-passenger</span> (runit) instead of sending a signal to the process.</p></div>
6359
+ </div>
6360
+ <div class="sect3">
6361
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="flying_passenger_caveats"></span><h4 data-comment-topic="caveats-and-limitations-lz3rbb" data-anchor="flying_passenger_caveats">9.9.5. Caveats and limitations</h4>
6362
+ <div class="paragraph"><p>Beware of the following caveats and limitations when using Flying Passenger:</p></div>
6363
+ <div class="ulist"><ul>
6364
+ <li>
6365
+ <p>
6366
+ The Nginx executable <strong>must</strong> be compiled with the same version of Phusion Passenger as the Flying Passenger daemon. Failing to meet this requirement may result in cryptic errors, or may result in certain features not working, until you’ve fixed the situation. When upgrading Phusion Passenger, you must restart both Nginx and the Flying Passenger daemon.
6367
+ </p>
6368
+ </li>
6369
+ <li>
6370
+ <p>
6371
+ The <a href="#PassengerRoot">passenger_root</a> directive has no effect. When using Flying Passenger, you are not supposed to set <span class="monospaced">passenger_root</span>.
6372
+ </p>
6373
+ </li>
6374
+ <li>
6375
+ <p>
6376
+ When you add a new application to the web server configuration, Flying Passenger will automatically pick up the application’s settings and spawn this new application upon the first request to it. However it is not capable of automatically starting the new app before a request has been sent to it (i.e. <a href="#PassengerPreStart">passenger_pre_start</a>-like behavior is not available in this case). As a workaround, you can send an HTTP request to your application after starting the daemon, which forces it to spawn application processes.
6377
+ </p>
6378
+ </li>
6379
+ <li>
6380
+ <p>
6381
+ When you remove an application from the web server configuration, Flying Passenger will not detect the removal and will not shut down the associated application processes. Killing the application processes will also not help, because Flying Passenger will restart them per the (now-removed, but still in the Flying Passenger daemon’s memory) <a href="#PassengerMinInstances">passenger_min_instances</a> settings. At the moment, there are two ways to get rid of those processes:
6382
+ </p>
6383
+ <div class="ulist"><ul>
6384
+ <li>
6385
+ <p>
6386
+ Before removing the application from the web server configuration, explicitly set its <span class="monospaced">passenger_min_instances</span> to 0. Next, send a request to it, which will cause the Flying Passenger daemon to take over the new <span class="monospaced">passenger_min_instances 0</span> option. You can then proceed with removing the application from the web server configuration, and restarting the web server. Finally, kill the PIDs associated to those application processes and remove the application configuration.
6387
+ </p>
6388
+ </li>
6389
+ <li>
6390
+ <p>
6391
+ Restart the Flying Passenger daemon.
6392
+ </p>
6393
+ </li>
6394
+ </ul></div>
6395
+ </li>
6396
+ </ul></div>
6397
+ </div>
6398
+ </div>
6399
+ <div class="sect2">
6400
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_x_sendfile_support"></span><h3 data-comment-topic="x-sendfile-support-1cgyykw" data-anchor="_x_sendfile_support">9.10. X-Sendfile support</h3>
5941
6401
  <div class="paragraph"><p>Phusion Passenger does not provide X-Sendfile support by itself. Please install
5942
6402
  <a href="http://tn123.ath.cx/mod_xsendfile/">mod_xsendfile</a> for X-Sendfile support.</p></div>
5943
6403
  </div>
5944
6404
  <div class="sect2">
5945
- <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_upload_progress"></span><h3 data-comment-topic="upload-progress-71cyl7" data-anchor="_upload_progress">9.10. Upload progress</h3>
6405
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_upload_progress"></span><h3 data-comment-topic="upload-progress-71cyl7" data-anchor="_upload_progress">9.11. Upload progress</h3>
5946
6406
  <div class="paragraph"><p>Phusion Passenger does not provide upload progress support by itself. Please
5947
6407
  try drogus’s <a href="http://github.com/drogus/apache-upload-progress-module/tree/master">
5948
6408
  Apache upload progress module</a> instead.</p></div>
@@ -6457,6 +6917,332 @@ has no effect.</p></div>
6457
6917
  </div>
6458
6918
  </div>
6459
6919
  </div>
6920
+ <div class="sect1">
6921
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="about_environment_variables"></span><h2 data-comment-topic="appendix-d-about-environment-variables-1lebv1u" data-anchor="about_environment_variables">14. Appendix D: About environment variables</h2>
6922
+ <div class="sectionbody">
6923
+ <div class="paragraph"><p>The Phusion Passenger compilation process can be customized with environment variables.</p></div>
6924
+ <div class="paragraph"><p>Environment variables are named values that affect how the system works. For example they tell the system where to look for commands (the <span class="monospaced">PATH</span> variable) or where to look for libraries (<span class="monospaced">LD_LIBRARY_PATH</span>). Their names are often in all-uppercase. Sometimes people refer to an environment variable with a dollar sign <span class="monospaced">$</span> in front, but that’s the same thing: when people say "the $PATH environment variable" they mean "the PATH environment variable". This is because the dollar sign <span class="monospaced">$</span> is a shell syntax for refering to an environment variable, as you will learn later.</p></div>
6925
+ <div class="paragraph"><p>Environment variables are set on a <strong>per-process</strong> basis, but they are <strong>inherited</strong> by child processes. This means that if you set environment variables in process A, another already running process B will not see these new environment variables. But if A spawns a child process C, then C will have all environment variables that A had. If you once again change the environment variables in A, then C will not see the changes.</p></div>
6926
+ <div class="paragraph"><p>The per-process nature of environment variables some implications. When you set environment variables in your <span class="monospaced">bashrc</span> or other bash startup files…</p></div>
6927
+ <div class="ulist"><ul>
6928
+ <li>
6929
+ <p>
6930
+ …only newly spawned bash shells see them.
6931
+ </p>
6932
+ </li>
6933
+ <li>
6934
+ <p>
6935
+ …the web server usually does not see them, because the web server tends to be started from init scripts, not from bash.
6936
+ </p>
6937
+ </li>
6938
+ <li>
6939
+ <p>
6940
+ …cron jobs do not see them, because cron jobs' environment variables are entirely dictated by their crontabs.
6941
+ </p>
6942
+ </li>
6943
+ </ul></div>
6944
+ <div class="admonitionblock">
6945
+ <table><tr>
6946
+ <td class="icon">
6947
+ <img src="./images/icons/note.png" alt="Note">
6948
+ </td>
6949
+ <td class="content">Because this chapter is meant for beginners, it assumes that the reader uses the bash shell. This chapter does not describe instructions for zsh, csh or other shells. We assume that users of other shells are familiar with the Bourne shell syntax, and know how to apply the instructions in this chapter in their shells' native syntaxes.</td>
6950
+ </tr></table>
6951
+ </div>
6952
+ <div class="sect2">
6953
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_working_with_environment_variables"></span><h3 data-comment-topic="working-with-environment-variables-85e6aa" data-anchor="_working_with_environment_variables">14.1. Working with environment variables</h3>
6954
+ <div class="paragraph"><p>You can see all environment variables in your shell by running the following command:</p></div>
6955
+ <div class="listingblock">
6956
+ <div class="content">
6957
+ <!-- Generator: GNU source-highlight 2.11.1
6958
+ by Lorenzo Bettini
6959
+ http://www.lorenzobettini.it
6960
+ http://www.gnu.org/software/src-highlite -->
6961
+ <pre><tt>env</tt></pre>
6962
+ </div>
6963
+ </div>
6964
+ <div class="paragraph"><p>You can set an evironment variable with the syntax <span class="monospaced">export &lt;NAME&gt;=&lt;VALUE&gt;</span>. For example, to set the <span class="monospaced">APXS2</span> variable to the value <span class="monospaced">/usr/sbin/apxs2</span>:</p></div>
6965
+ <div class="listingblock">
6966
+ <div class="content">
6967
+ <!-- Generator: GNU source-highlight 2.11.1
6968
+ by Lorenzo Bettini
6969
+ http://www.lorenzobettini.it
6970
+ http://www.gnu.org/software/src-highlite -->
6971
+ <pre><tt><span style="font-weight: bold"><span style="color: #0000FF">export</span></span> <span style="color: #009900">APXS2</span><span style="color: #990000">=</span>/usr/sbin/apxs<span style="color: #993399">2</span></tt></pre>
6972
+ </div>
6973
+ </div>
6974
+ <div class="paragraph"><p>Any process that you run from your shell from that point on will have said environment variable:</p></div>
6975
+ <div class="listingblock">
6976
+ <div class="content">
6977
+ <!-- Generator: GNU source-highlight 2.11.1
6978
+ by Lorenzo Bettini
6979
+ http://www.lorenzobettini.it
6980
+ http://www.gnu.org/software/src-highlite -->
6981
+ <pre><tt><span style="font-weight: bold"><span style="color: #0000FF">export</span></span> <span style="color: #009900">APXS2</span><span style="color: #990000">=</span>/usr/sbin/apxs<span style="color: #993399">2</span>
6982
+ ruby -e <span style="color: #FF0000">'p ENV["APXS2"]'</span>
6983
+ <span style="font-style: italic"><span style="color: #9A1900"># =&gt; "/usr/sbin/apxs2"</span></span></tt></pre>
6984
+ </div>
6985
+ </div>
6986
+ <div class="admonitionblock">
6987
+ <table><tr>
6988
+ <td class="icon">
6989
+ <img src="./images/icons/note.png" alt="Note">
6990
+ </td>
6991
+ <td class="content">
6992
+ <div class="title">The "export" keyword is important</div>
6993
+ <div class="paragraph"><p>You <strong>must</strong> set the <span class="monospaced">export</span> keyword. If you omit the <span class="monospaced">export</span> keyword then the environment variable will not be visible to other processes:</p></div>
6994
+ <div class="listingblock">
6995
+ <div class="content">
6996
+ <!-- Generator: GNU source-highlight 2.11.1
6997
+ by Lorenzo Bettini
6998
+ http://www.lorenzobettini.it
6999
+ http://www.gnu.org/software/src-highlite -->
7000
+ <pre><tt><span style="color: #009900">APXS2</span><span style="color: #990000">=</span>/usr/sbin/apxs<span style="color: #993399">2</span>
7001
+ ruby -e <span style="color: #FF0000">'p ENV["APXS2"]'</span>
7002
+ <span style="font-style: italic"><span style="color: #9A1900"># =&gt; nil</span></span></tt></pre>
7003
+ </div>
7004
+ </div>
7005
+ </td>
7006
+ </tr></table>
7007
+ </div>
7008
+ <div class="paragraph"><p>You can reference an environment variable in your shell by typing the <span class="monospaced">$</span> sign followed by the environment variable’s name. For example, to see the value of the <span class="monospaced">PATH</span> variable:</p></div>
7009
+ <div class="listingblock">
7010
+ <div class="content">
7011
+ <!-- Generator: GNU source-highlight 2.11.1
7012
+ by Lorenzo Bettini
7013
+ http://www.lorenzobettini.it
7014
+ http://www.gnu.org/software/src-highlite -->
7015
+ <pre><tt>echo <span style="color: #009900">$PATH</span></tt></pre>
7016
+ </div>
7017
+ </div>
7018
+ <div class="paragraph"><p>You can also use this trick to extend the value of an environment variable:</p></div>
7019
+ <div class="listingblock">
7020
+ <div class="content">
7021
+ <!-- Generator: GNU source-highlight 2.11.1
7022
+ by Lorenzo Bettini
7023
+ http://www.lorenzobettini.it
7024
+ http://www.gnu.org/software/src-highlite -->
7025
+ <pre><tt><span style="font-weight: bold"><span style="color: #0000FF">export</span></span> <span style="color: #009900">PATH</span><span style="color: #990000">=</span>/usr/bin
7026
+
7027
+ <span style="font-style: italic"><span style="color: #9A1900"># Prepends '/opt/local/bin', so that it becomes /opt/local/bin:/usr/bin</span></span>
7028
+ <span style="font-weight: bold"><span style="color: #0000FF">export</span></span> <span style="color: #009900">PATH</span><span style="color: #990000">=</span>/opt/local/bin<span style="color: #990000">:</span><span style="color: #009900">$PATH</span>
7029
+ <span style="font-style: italic"><span style="color: #9A1900"># Appends '/usr/local/bin', so that it becomes /opt/local/bin:/usr/bin:/usr/local/bin</span></span>
7030
+ <span style="font-weight: bold"><span style="color: #0000FF">export</span></span> <span style="color: #009900">PATH</span><span style="color: #990000">=</span><span style="color: #009900">$PATH</span><span style="color: #990000">:</span>/usr/local/bin</tt></pre>
7031
+ </div>
7032
+ </div>
7033
+ </div>
7034
+ <div class="sect2">
7035
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_the_path_environment_variable"></span><h3 data-comment-topic="the-path-environment-variable-p8e32r" data-anchor="_the_path_environment_variable">14.2. The PATH environment variable</h3>
7036
+ <div class="paragraph"><p>The <span class="monospaced">PATH</span> environment variable dictates where the system looks for command. It is a colon-separated list of directories. If you get a "command not found" error while you know that the command is installed, then setting <span class="monospaced">PATH</span> will help. For example suppose that the command <span class="monospaced">frobnicator</span> is in <span class="monospaced">/opt/local/bin</span>:</p></div>
7037
+ <div class="listingblock">
7038
+ <div class="content">
7039
+ <!-- Generator: GNU source-highlight 2.11.1
7040
+ by Lorenzo Bettini
7041
+ http://www.lorenzobettini.it
7042
+ http://www.gnu.org/software/src-highlite -->
7043
+ <pre><tt>user@localhost bash$ frobnicator
7044
+ bash<span style="color: #990000">:</span> frobnicator<span style="color: #990000">:</span> <span style="font-weight: bold"><span style="color: #0000FF">command</span></span> not found</tt></pre>
7045
+ </div>
7046
+ </div>
7047
+ <div class="paragraph"><p>We verify that <span class="monospaced">/opt/local/bin</span> is not in <span class="monospaced">PATH</span>:</p></div>
7048
+ <div class="listingblock">
7049
+ <div class="content">
7050
+ <!-- Generator: GNU source-highlight 2.11.1
7051
+ by Lorenzo Bettini
7052
+ http://www.lorenzobettini.it
7053
+ http://www.gnu.org/software/src-highlite -->
7054
+ <pre><tt>user@localhost bash$ echo <span style="color: #009900">$PATH</span>
7055
+ /bin<span style="color: #990000">:</span>/usr/bin<span style="color: #990000">:</span>/usr/local/bin</tt></pre>
7056
+ </div>
7057
+ </div>
7058
+ <div class="paragraph"><p>We can run <span class="monospaced">frobnicator</span> through it’s full path…</p></div>
7059
+ <div class="listingblock">
7060
+ <div class="content">
7061
+ <!-- Generator: GNU source-highlight 2.11.1
7062
+ by Lorenzo Bettini
7063
+ http://www.lorenzobettini.it
7064
+ http://www.gnu.org/software/src-highlite -->
7065
+ <pre><tt>user@localhost bash$ /opt/local/bin/frobnicator
7066
+ <span style="font-style: italic"><span style="color: #9A1900"># =&gt; success!</span></span></tt></pre>
7067
+ </div>
7068
+ </div>
7069
+ <div class="paragraph"><p>…or we can add <span class="monospaced">/opt/local/bin</span> to <span class="monospaced">PATH</span>.</p></div>
7070
+ <div class="listingblock">
7071
+ <div class="content">
7072
+ <!-- Generator: GNU source-highlight 2.11.1
7073
+ by Lorenzo Bettini
7074
+ http://www.lorenzobettini.it
7075
+ http://www.gnu.org/software/src-highlite -->
7076
+ <pre><tt>user@localhost bash$ <span style="font-weight: bold"><span style="color: #0000FF">export</span></span> <span style="color: #009900">PATH</span><span style="color: #990000">=</span><span style="color: #009900">$PATH</span><span style="color: #990000">:</span>/opt/local/bin
7077
+ user@localhost bash$ frobnicator
7078
+ <span style="font-style: italic"><span style="color: #9A1900"># =&gt; success!</span></span></tt></pre>
7079
+ </div>
7080
+ </div>
7081
+ </div>
7082
+ <div class="sect2">
7083
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_making_environment_variables_permanent"></span><h3 data-comment-topic="making-environment-variables-permanent-13x0l4h" data-anchor="_making_environment_variables_permanent">14.3. Making environment variables permanent</h3>
7084
+ <div class="paragraph"><p>When you exit your shell, the evironment variable changes are lost. There is no standard method to set environment variables system-wide, so you have to set them in different configuration files for different services.</p></div>
7085
+ <div class="sect3">
7086
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_bash"></span><h4 data-comment-topic="bash-1pktn63" data-anchor="_bash">14.3.1. bash</h4>
7087
+ <div class="paragraph"><p>To make environment variables permanent for future bash sessions <strong>for the current user</strong>, add them to your <span class="monospaced">~/.bashrc</span>:</p></div>
7088
+ <div class="listingblock">
7089
+ <div class="content">
7090
+ <!-- Generator: GNU source-highlight 2.11.1
7091
+ by Lorenzo Bettini
7092
+ http://www.lorenzobettini.it
7093
+ http://www.gnu.org/software/src-highlite -->
7094
+ <pre><tt>echo <span style="color: #FF0000">'export FOO=bar'</span> <span style="color: #990000">&gt;&gt;</span> <span style="color: #990000">~/.</span>bashrc
7095
+ echo <span style="color: #FF0000">'export PATH=/usr/local/bin:$PATH'</span> <span style="color: #990000">&gt;&gt;</span> <span style="color: #990000">~/.</span>bashrc</tt></pre>
7096
+ </div>
7097
+ </div>
7098
+ <div class="paragraph"><p>To make them permanent for future bash sessions <strong>for all users</strong>, add them to <span class="monospaced">/etc/bashrc</span>.</p></div>
7099
+ <div class="admonitionblock">
7100
+ <table><tr>
7101
+ <td class="icon">
7102
+ <img src="./images/icons/note.png" alt="Note">
7103
+ </td>
7104
+ <td class="content">Depending on the system, the bashrc file may have a different filename. On Debian and Ubuntu, it’s <span class="monospaced">/etc/bash.bashrc</span>.</td>
7105
+ </tr></table>
7106
+ </div>
7107
+ </div>
7108
+ <div class="sect3">
7109
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_apache"></span><h4 data-comment-topic="apache-15zqjvi" data-anchor="_apache">14.3.2. Apache</h4>
7110
+ <div class="admonitionblock">
7111
+ <table><tr>
7112
+ <td class="icon">
7113
+ <img src="./images/icons/note.png" alt="Note">
7114
+ </td>
7115
+ <td class="content">This subsection describes how to set environment variables on Apache itself, not on apps served through Phusion Passenger for Apache. The environment variables you set here will be passed to all apps, but you cannot customize them on a per-app basis. See also <a href="#env_vars_passenger_apps">Setting environment variables on Phusion Passenger-served apps</a>.</td>
7116
+ </tr></table>
7117
+ </div>
7118
+ <div class="paragraph"><p>On Debian and Ubuntu, with an Apache installed through apt, Apache environment variables are defined in the file <span class="monospaced">/etc/apache2/envvars</span>. This is a shell script so environment variables must be specified with the shell syntax.</p></div>
7119
+ <div class="paragraph"><p>On Red Hat, Fedora, CentOS and ScientificLinux, with an Apache installed through YUM, Apache environment variables are defined in <span class="monospaced">/etc/sysconfig/httpd</span>.</p></div>
7120
+ <div class="paragraph"><p>On OS X they are defined in <span class="monospaced">/System/Library/LaunchDaemons/org.apache.httpd.plist</span>, as explained <a href="/System/Library/LaunchDaemons/org.apache.httpd.plist">here on Stack Overflow</a>.</p></div>
7121
+ <div class="paragraph"><p>On other systems, or if you did not install Apache through the system’s package manager, the configuration file for environment variables is specific to the vendor that supplied Apache. There may not even be such a configuration file. You should contact the vendor for support.</p></div>
7122
+ </div>
7123
+ <div class="sect3">
7124
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_nginx"></span><h4 data-comment-topic="nginx-l7ztbb" data-anchor="_nginx">14.3.3. Nginx</h4>
7125
+ <div class="admonitionblock">
7126
+ <table><tr>
7127
+ <td class="icon">
7128
+ <img src="./images/icons/note.png" alt="Note">
7129
+ </td>
7130
+ <td class="content">This subsection describes how to set environment variables on Nginx itself, not on apps served through Phusion Passenger for Nginx. The environment variables you set here will be passed to all apps, but you cannot customize them on a per-app basis. See also <a href="#env_vars_passenger_apps">Setting environment variables on Phusion Passenger-served apps</a>.</td>
7131
+ </tr></table>
7132
+ </div>
7133
+ <div class="paragraph"><p>If you installed Nginx through <a href="#install_on_debian_ubuntu">the Brightbox packages</a>, then you can define environment variables in <span class="monospaced">/etc/default/nginx</span>. This is a shell script so you must use the <span class="monospaced">export FOO=bar</span> syntax.</p></div>
7134
+ <div class="paragraph"><p>Otherwise, environment variables are best set through the script which starts Nginx. For example, if you installed Nginx from source and you used
7135
+ the Nginx init script described in the <a href="http://www.modrails.com/documentation/Users%20guide%20Nginx.html">Phusion Passenger Users Guide, Nginx version</a>,
7136
+ then you should edit that script to define the environment variables. Those init scripts are regular shell scripts, so use the <span class="monospaced">export FOO=bar</span> syntax. Just make sure your set your environment variables before the script starts Nginx.</p></div>
7137
+ <div class="admonitionblock">
7138
+ <table><tr>
7139
+ <td class="icon">
7140
+ <img src="./images/icons/note.png" alt="Note">
7141
+ </td>
7142
+ <td class="content">Setting environment variables on Nginx has no effect on the <a href="#flying_passenger">Flying Passenger daemon</a> because the daemon is started seperately. You should set the environment variables in the shell right before starting the daemon.</td>
7143
+ </tr></table>
7144
+ </div>
7145
+ </div>
7146
+ <div class="sect3">
7147
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="_cron"></span><h4 data-comment-topic="cron-1kjp7ck" data-anchor="_cron">14.3.4. cron</h4>
7148
+ <div class="paragraph"><p>To make environment variables permanent for cron jobs, add those variables to the relevant crontab. But note that inside crontabs you cannot refer to existing environment variables with the <span class="monospaced">$</span> syntax because crontabs are not shell scripts. You have to specify the entire value.</p></div>
7149
+ <div class="listingblock">
7150
+ <div class="title">What to put in "crontab -e"</div>
7151
+ <div class="content monospaced">
7152
+ <pre># Environment variable definitions
7153
+ FOO=bar
7154
+ APXS2=/usr/sbin/apxs2
7155
+
7156
+ # **WRONG!** You cannot refer to existing variables with the `$` syntax!
7157
+ PATH=/usr/bin:$PATH
7158
+ # **WRONG!** You cannot use the 'export' keyword!
7159
+ export PATH=/usr/bin:/usr/local/bin
7160
+ # Correct:
7161
+ PATH=/usr/bin:/usr/local/bin
7162
+
7163
+ # Jobs:
7164
+ # m h dom mon dow command
7165
+ * * * * * frobnicator</pre>
7166
+ </div>
7167
+ </div>
7168
+ </div>
7169
+ <div class="sect3">
7170
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="env_vars_passenger_apps"></span><h4 data-comment-topic="phusion-passenger-served-apps-478vyt" data-anchor="env_vars_passenger_apps">14.3.5. Phusion Passenger-served apps</h4>
7171
+ <div class="paragraph"><p>You can pass environment variables to Phusion Passenger-served apps through various methods:</p></div>
7172
+ <div class="ulist"><ul>
7173
+ <li>
7174
+ <p>
7175
+ When running Apache, use the <span class="monospaced">PassEnv</span> and <span class="monospaced">SetEnv</span> directives of <a href="http://httpd.apache.org/docs/2.4/mod/mod_env.html">mod_env</a>. This is supported starting from Phusion Passenger 4.0.
7176
+ </p>
7177
+ </li>
7178
+ <li>
7179
+ <p>
7180
+ When running Nginx, use the <span class="monospaced">env</span> directive. Unlike Apache, Nginx’s <span class="monospaced">env</span> directive can only be set globally and cannot be customized on a per-virtual host basis.
7181
+ </p>
7182
+ </li>
7183
+ <li>
7184
+ <p>
7185
+ Through your <span class="monospaced">bashrc</span>. Starting from version 4.0, Phusion Passenger 4.0 spawns applications through bash and inherit all bash environment variables. Phusion Passenger Standalone tends to be started from the shell and thus inherits all environment variables set by the shell.
7186
+ </p>
7187
+ </li>
7188
+ <li>
7189
+ <p>
7190
+ Through Apache and Nginx, as described earlier in this chapter. Any environment variables that you set on Apache and Nginx itself are inherited by Phusion Passenger, and thus by Phusion Passenger-served apps as well.
7191
+ </p>
7192
+ </li>
7193
+ <li>
7194
+ <p>
7195
+ Through the application itself. Most programming languages provide APIs for setting environment variables. For example in Ruby you can write:
7196
+ </p>
7197
+ <div class="listingblock">
7198
+ <div class="content">
7199
+ <!-- Generator: GNU source-highlight 2.11.1
7200
+ by Lorenzo Bettini
7201
+ http://www.lorenzobettini.it
7202
+ http://www.gnu.org/software/src-highlite -->
7203
+ <pre><tt>ENV<span style="color: #990000">[</span><span style="color: #FF0000">'FOO'</span><span style="color: #990000">]</span> <span style="color: #990000">=</span> <span style="color: #FF0000">'bar'</span></tt></pre>
7204
+ </div>
7205
+ </div>
7206
+ <div class="paragraph"><p>In Python you can write:</p></div>
7207
+ <div class="listingblock">
7208
+ <div class="content">
7209
+ <!-- Generator: GNU source-highlight 2.11.1
7210
+ by Lorenzo Bettini
7211
+ http://www.lorenzobettini.it
7212
+ http://www.gnu.org/software/src-highlite -->
7213
+ <pre><tt><span style="font-weight: bold"><span style="color: #000080">import</span></span> os
7214
+ os<span style="color: #990000">.</span>environ<span style="color: #990000">[</span><span style="color: #FF0000">'FOO'</span><span style="color: #990000">]</span> <span style="color: #990000">=</span> <span style="color: #FF0000">'bar'</span></tt></pre>
7215
+ </div>
7216
+ </div>
7217
+ </li>
7218
+ </ul></div>
7219
+ </div>
7220
+ </div>
7221
+ <div class="sect2">
7222
+ <a href="javascript:void(0)" class="comments empty" title="Add a comment"><span class="count"></span></a><span class="anchor_helper" id="env_vars_and_sudo"></span><h3 data-comment-topic="environment-variables-and-sudo-1odzcpz" data-anchor="env_vars_and_sudo">14.4. Environment variables and sudo</h3>
7223
+ <div class="paragraph"><p>The <span class="monospaced">sudo</span> command resets all environment variables before running the specified command, for security reasons. So if you set environment variables before running <span class="monospaced">sudo passenger-install-xxx-module</span>, <span class="monospaced">sudo passenger-status</span> or any other commands, then the environment variables are not correctly passed to the command. You can solve this by running sudo with <span class="monospaced">-E</span> (preserve environment variables):</p></div>
7224
+ <div class="listingblock">
7225
+ <div class="content">
7226
+ <!-- Generator: GNU source-highlight 2.11.1
7227
+ by Lorenzo Bettini
7228
+ http://www.lorenzobettini.it
7229
+ http://www.gnu.org/software/src-highlite -->
7230
+ <pre><tt>user@localhost bash$ <span style="font-weight: bold"><span style="color: #0000FF">export</span></span> <span style="color: #009900">APXS2</span><span style="color: #990000">=</span>/usr/sbin/apxs<span style="color: #993399">2</span>
7231
+ user@localhost bash$ sudo -E passenger-install-apache<span style="color: #993399">2</span>-module</tt></pre>
7232
+ </div>
7233
+ </div>
7234
+ <div class="paragraph"><p>Alternatively, you can obtain a root prompt with sudo first, and <strong>then</strong> set the environment variables, before running any further commands:</p></div>
7235
+ <div class="listingblock">
7236
+ <div class="content monospaced">
7237
+ <pre>user@localhost bash$ sudo -s
7238
+ Password: ...
7239
+ root@localhost bash# export APXS2=/usr/sbin/apxs2
7240
+ root@localhost bash# passenger-install-apache2-module</pre>
7241
+ </div>
7242
+ </div>
7243
+ </div>
7244
+ </div>
7245
+ </div>
6460
7246
  </div>
6461
7247
  <div id="footnotes"><hr></div>
6462
7248
  <div id="footer">