passenger 2.0.6 → 2.1.2

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 (497) hide show
  1. data/DEVELOPERS.TXT +10 -4
  2. data/LICENSE +1 -1
  3. data/NEWS +0 -0
  4. data/Rakefile +183 -117
  5. data/benchmark/dispatcher.rb +5 -9
  6. data/bin/passenger-install-apache2-module +52 -18
  7. data/bin/passenger-memory-stats +67 -13
  8. data/bin/passenger-spawn-server +8 -4
  9. data/bin/passenger-status +21 -46
  10. data/bin/passenger-stress-test +5 -5
  11. data/debian/postinst +1 -1
  12. data/doc/ApplicationPool algorithm.txt +180 -128
  13. data/doc/Architectural overview.html +1 -778
  14. data/doc/Security of user switching support.html +1 -643
  15. data/doc/Users guide Apache.html +3127 -0
  16. data/doc/Users guide Nginx.html +1458 -0
  17. data/doc/Users guide.html +1404 -467
  18. data/doc/Users guide.txt +843 -105
  19. data/doc/cxxapi/ApplicationPoolServer_8h-source.html +751 -641
  20. data/doc/cxxapi/ApplicationPool_8h-source.html +168 -171
  21. data/doc/cxxapi/Application_8h-source.html +494 -394
  22. data/doc/cxxapi/Bucket_8h-source.html +21 -15
  23. data/doc/cxxapi/CachedFileStat_8h-source.html +191 -0
  24. data/doc/cxxapi/Configuration_8h-source.html +311 -149
  25. data/doc/cxxapi/DirectoryMapper_8h-source.html +309 -0
  26. data/doc/cxxapi/DummySpawnManager_8h-source.html +3 -4
  27. data/doc/cxxapi/Exceptions_8h-source.html +182 -165
  28. data/doc/cxxapi/FileChecker_8h-source.html +130 -0
  29. data/doc/cxxapi/Hooks_8h-source.html +2 -3
  30. data/doc/cxxapi/Logging_8h-source.html +92 -89
  31. data/doc/cxxapi/MessageChannel_8h-source.html +585 -477
  32. data/doc/cxxapi/PoolOptions_8h-source.html +305 -0
  33. data/doc/cxxapi/SpawnManager_8h-source.html +515 -540
  34. data/doc/cxxapi/StandardApplicationPool_8h-source.html +779 -679
  35. data/doc/cxxapi/SystemTime_8h-source.html +104 -0
  36. data/doc/cxxapi/Utils_8h-source.html +331 -227
  37. data/doc/cxxapi/annotated.html +6 -7
  38. data/doc/cxxapi/classClient-members.html +1 -2
  39. data/doc/cxxapi/classClient.html +1 -2
  40. data/doc/cxxapi/classHooks-members.html +5 -2
  41. data/doc/cxxapi/classHooks.html +112 -2
  42. data/doc/cxxapi/classPassenger_1_1Application-members.html +2 -3
  43. data/doc/cxxapi/classPassenger_1_1Application.html +8 -9
  44. data/doc/cxxapi/classPassenger_1_1ApplicationPool-members.html +4 -4
  45. data/doc/cxxapi/classPassenger_1_1ApplicationPool.html +42 -81
  46. data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer-members.html +1 -2
  47. data/doc/cxxapi/classPassenger_1_1ApplicationPoolServer.html +3 -4
  48. data/doc/cxxapi/classPassenger_1_1ApplicationPool__inherit__graph.png +0 -0
  49. data/doc/cxxapi/classPassenger_1_1Application_1_1Session-members.html +3 -2
  50. data/doc/cxxapi/classPassenger_1_1Application_1_1Session.html +74 -3
  51. data/doc/cxxapi/classPassenger_1_1BusyException-members.html +1 -2
  52. data/doc/cxxapi/classPassenger_1_1BusyException.html +2 -3
  53. data/doc/cxxapi/classPassenger_1_1ConfigurationException-members.html +1 -2
  54. data/doc/cxxapi/classPassenger_1_1ConfigurationException.html +2 -3
  55. data/doc/cxxapi/classPassenger_1_1DirectoryMapper-members.html +38 -0
  56. data/doc/cxxapi/classPassenger_1_1DirectoryMapper.html +256 -0
  57. data/doc/cxxapi/classPassenger_1_1DummySpawnManager-members.html +1 -2
  58. data/doc/cxxapi/classPassenger_1_1DummySpawnManager.html +2 -3
  59. data/doc/cxxapi/{classPassenger_1_1Thread-members.html → classPassenger_1_1FileChecker-members.html} +4 -5
  60. data/doc/cxxapi/classPassenger_1_1FileChecker.html +121 -0
  61. data/doc/cxxapi/classPassenger_1_1FileNotFoundException-members.html +1 -2
  62. data/doc/cxxapi/classPassenger_1_1FileNotFoundException.html +2 -3
  63. data/doc/cxxapi/classPassenger_1_1FileNotFoundException__inherit__graph.png +0 -0
  64. data/doc/cxxapi/classPassenger_1_1FileSystemException-members.html +2 -3
  65. data/doc/cxxapi/classPassenger_1_1FileSystemException.html +2 -3
  66. data/doc/cxxapi/classPassenger_1_1FileSystemException__inherit__graph.png +0 -0
  67. data/doc/cxxapi/classPassenger_1_1IOException-members.html +1 -2
  68. data/doc/cxxapi/classPassenger_1_1IOException.html +2 -3
  69. data/doc/cxxapi/classPassenger_1_1IOException__inherit__graph.png +0 -0
  70. data/doc/cxxapi/classPassenger_1_1MessageChannel-members.html +5 -2
  71. data/doc/cxxapi/classPassenger_1_1MessageChannel.html +155 -5
  72. data/doc/cxxapi/{classboost_1_1this__thread_1_1enable__syscall__interruption-members.html → classPassenger_1_1RuntimeException-members.html} +2 -3
  73. data/doc/cxxapi/{classboost_1_1this__thread_1_1enable__syscall__interruption.html → classPassenger_1_1RuntimeException.html} +10 -8
  74. data/doc/cxxapi/classPassenger_1_1SpawnException-members.html +1 -2
  75. data/doc/cxxapi/classPassenger_1_1SpawnException.html +2 -3
  76. data/doc/cxxapi/classPassenger_1_1SpawnManager-members.html +2 -3
  77. data/doc/cxxapi/classPassenger_1_1SpawnManager.html +15 -56
  78. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool-members.html +5 -4
  79. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool.html +20 -81
  80. data/doc/cxxapi/classPassenger_1_1StandardApplicationPool__inherit__graph.png +0 -0
  81. data/doc/cxxapi/classPassenger_1_1SystemException-members.html +2 -3
  82. data/doc/cxxapi/classPassenger_1_1SystemException.html +9 -10
  83. data/doc/cxxapi/classPassenger_1_1SystemException__inherit__graph.png +0 -0
  84. data/doc/cxxapi/{classboost_1_1this__thread_1_1disable__syscall__interruption-members.html → classPassenger_1_1SystemTime-members.html} +5 -3
  85. data/doc/cxxapi/classPassenger_1_1SystemTime.html +86 -0
  86. data/doc/cxxapi/classPassenger_1_1TempFile-members.html +2 -3
  87. data/doc/cxxapi/classPassenger_1_1TempFile.html +17 -9
  88. data/doc/cxxapi/definitions_8h-source.html +1 -2
  89. data/doc/cxxapi/files.html +6 -3
  90. data/doc/cxxapi/functions.html +98 -35
  91. data/doc/cxxapi/functions_func.html +60 -32
  92. data/doc/cxxapi/functions_type.html +1 -2
  93. data/doc/cxxapi/functions_vars.html +27 -2
  94. data/doc/cxxapi/graph_legend.html +1 -2
  95. data/doc/cxxapi/graph_legend.png +0 -0
  96. data/doc/cxxapi/group__Configuration.html +3 -4
  97. data/doc/cxxapi/group__Configuration.png +0 -0
  98. data/doc/cxxapi/group__Core.html +3 -4
  99. data/doc/cxxapi/group__Core.png +0 -0
  100. data/doc/cxxapi/group__Exceptions.html +4 -2
  101. data/doc/cxxapi/group__Hooks.html +1 -6
  102. data/doc/cxxapi/group__Hooks.png +0 -0
  103. data/doc/cxxapi/group__Support.html +259 -36
  104. data/doc/cxxapi/hierarchy.html +6 -7
  105. data/doc/cxxapi/inherit__graph__0.map +1 -1
  106. data/doc/cxxapi/inherit__graph__0.md5 +1 -1
  107. data/doc/cxxapi/inherit__graph__0.png +0 -0
  108. data/doc/cxxapi/inherit__graph__1.map +1 -1
  109. data/doc/cxxapi/inherit__graph__1.md5 +1 -1
  110. data/doc/cxxapi/inherit__graph__1.png +0 -0
  111. data/doc/cxxapi/inherit__graph__10.map +1 -1
  112. data/doc/cxxapi/inherit__graph__10.md5 +1 -1
  113. data/doc/cxxapi/inherit__graph__10.png +0 -0
  114. data/doc/cxxapi/inherit__graph__11.map +1 -1
  115. data/doc/cxxapi/inherit__graph__11.md5 +1 -1
  116. data/doc/cxxapi/inherit__graph__11.png +0 -0
  117. data/doc/cxxapi/inherit__graph__12.map +2 -1
  118. data/doc/cxxapi/inherit__graph__12.md5 +1 -1
  119. data/doc/cxxapi/inherit__graph__12.png +0 -0
  120. data/doc/cxxapi/inherit__graph__13.map +1 -1
  121. data/doc/cxxapi/inherit__graph__13.md5 +1 -1
  122. data/doc/cxxapi/inherit__graph__13.png +0 -0
  123. data/doc/cxxapi/inherit__graph__14.map +1 -2
  124. data/doc/cxxapi/inherit__graph__14.md5 +1 -1
  125. data/doc/cxxapi/inherit__graph__14.png +0 -0
  126. data/doc/cxxapi/inherit__graph__15.map +1 -1
  127. data/doc/cxxapi/inherit__graph__15.md5 +1 -1
  128. data/doc/cxxapi/inherit__graph__15.png +0 -0
  129. data/doc/cxxapi/inherit__graph__16.map +1 -1
  130. data/doc/cxxapi/inherit__graph__16.md5 +1 -1
  131. data/doc/cxxapi/inherit__graph__16.png +0 -0
  132. data/doc/cxxapi/inherit__graph__17.png +0 -0
  133. data/doc/cxxapi/inherit__graph__18.png +0 -0
  134. data/doc/cxxapi/inherit__graph__19.png +0 -0
  135. data/doc/cxxapi/inherit__graph__2.map +1 -1
  136. data/doc/cxxapi/inherit__graph__2.md5 +1 -1
  137. data/doc/cxxapi/inherit__graph__2.png +0 -0
  138. data/doc/cxxapi/inherit__graph__20.map +1 -1
  139. data/doc/cxxapi/inherit__graph__20.md5 +1 -1
  140. data/doc/cxxapi/inherit__graph__20.png +0 -0
  141. data/doc/cxxapi/inherit__graph__21.map +1 -1
  142. data/doc/cxxapi/inherit__graph__21.md5 +1 -1
  143. data/doc/cxxapi/inherit__graph__21.png +0 -0
  144. data/doc/cxxapi/inherit__graph__3.map +1 -1
  145. data/doc/cxxapi/inherit__graph__3.md5 +1 -1
  146. data/doc/cxxapi/inherit__graph__3.png +0 -0
  147. data/doc/cxxapi/inherit__graph__4.map +1 -1
  148. data/doc/cxxapi/inherit__graph__4.md5 +1 -1
  149. data/doc/cxxapi/inherit__graph__4.png +0 -0
  150. data/doc/cxxapi/inherit__graph__5.map +2 -1
  151. data/doc/cxxapi/inherit__graph__5.md5 +1 -1
  152. data/doc/cxxapi/inherit__graph__5.png +0 -0
  153. data/doc/cxxapi/inherit__graph__6.map +1 -1
  154. data/doc/cxxapi/inherit__graph__6.md5 +1 -1
  155. data/doc/cxxapi/inherit__graph__6.png +0 -0
  156. data/doc/cxxapi/inherit__graph__7.map +1 -1
  157. data/doc/cxxapi/inherit__graph__7.md5 +1 -1
  158. data/doc/cxxapi/inherit__graph__7.png +0 -0
  159. data/doc/cxxapi/inherit__graph__8.map +1 -1
  160. data/doc/cxxapi/inherit__graph__8.md5 +1 -1
  161. data/doc/cxxapi/inherit__graph__8.png +0 -0
  162. data/doc/cxxapi/inherit__graph__9.map +1 -2
  163. data/doc/cxxapi/inherit__graph__9.md5 +1 -1
  164. data/doc/cxxapi/inherit__graph__9.png +0 -0
  165. data/doc/cxxapi/inherits.html +30 -31
  166. data/doc/cxxapi/main.html +1 -2
  167. data/doc/cxxapi/modules.html +1 -2
  168. data/doc/cxxapi/structPassenger_1_1AnythingToString-members.html +1 -2
  169. data/doc/cxxapi/structPassenger_1_1AnythingToString.html +2 -3
  170. data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4-members.html +1 -2
  171. data/doc/cxxapi/structPassenger_1_1AnythingToString_3_01vector_3_01string_01_4_01_4.html +2 -3
  172. data/doc/cxxapi/structPassenger_1_1PoolOptions-members.html +49 -0
  173. data/doc/cxxapi/structPassenger_1_1PoolOptions.html +404 -0
  174. data/doc/cxxapi/tree.html +18 -20
  175. data/doc/images/conservative_spawning.png +0 -0
  176. data/doc/images/conservative_spawning.svg +248 -0
  177. data/doc/images/smart-lv2.png +0 -0
  178. data/doc/images/smart-lv2.svg +320 -0
  179. data/doc/rdoc/classes/ConditionVariable.html +68 -34
  180. data/doc/rdoc/classes/Exception.html +16 -16
  181. data/doc/rdoc/classes/GC.html +9 -9
  182. data/doc/rdoc/classes/IO.html +36 -17
  183. data/doc/rdoc/classes/PhusionPassenger.html +183 -0
  184. data/doc/rdoc/classes/PhusionPassenger/AbstractRequestHandler.html +511 -0
  185. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer.html +285 -242
  186. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer/ServerAlreadyStarted.html +3 -3
  187. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer/ServerError.html +3 -3
  188. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer/ServerNotStarted.html +3 -3
  189. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AbstractServer/UnknownMessage.html +3 -3
  190. data/doc/rdoc/classes/PhusionPassenger/AbstractServerCollection.html +598 -0
  191. data/doc/rdoc/classes/PhusionPassenger/AdminTools.html +140 -0
  192. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess.html +247 -0
  193. data/doc/rdoc/classes/PhusionPassenger/AdminTools/ControlProcess/Instance.html +138 -0
  194. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/AppInitError.html +36 -19
  195. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/Application.html +81 -96
  196. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/ConsoleTextTemplate.html +18 -18
  197. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/FrameworkInitError.html +20 -18
  198. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/HTMLTemplate.html +18 -18
  199. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/InitializationError.html +9 -9
  200. data/doc/rdoc/classes/PhusionPassenger/InvalidPath.html +92 -0
  201. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/MessageChannel.html +93 -92
  202. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/NativeSupport.html +55 -25
  203. data/doc/rdoc/classes/PhusionPassenger/Rack.html +91 -0
  204. data/doc/rdoc/classes/PhusionPassenger/Rack/ApplicationSpawner.html +185 -0
  205. data/doc/rdoc/classes/PhusionPassenger/Rack/RequestHandler.html +182 -0
  206. data/doc/rdoc/classes/PhusionPassenger/Railz.html +95 -0
  207. data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner.html +424 -0
  208. data/doc/rdoc/classes/PhusionPassenger/Railz/ApplicationSpawner/Error.html +98 -0
  209. data/doc/rdoc/classes/PhusionPassenger/Railz/CGIFixed.html +200 -0
  210. data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner.html +444 -0
  211. data/doc/rdoc/classes/PhusionPassenger/Railz/FrameworkSpawner/Error.html +98 -0
  212. data/doc/rdoc/classes/PhusionPassenger/Railz/RequestHandler.html +154 -0
  213. data/doc/rdoc/classes/PhusionPassenger/SpawnManager.html +408 -0
  214. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/UnknownError.html +13 -13
  215. data/doc/rdoc/classes/PhusionPassenger/Utils.html +687 -0
  216. data/doc/rdoc/classes/{Passenger → PhusionPassenger}/VersionNotFound.html +8 -8
  217. data/doc/rdoc/classes/PhusionPassenger/WSGI.html +89 -0
  218. data/doc/rdoc/classes/PhusionPassenger/WSGI/ApplicationSpawner.html +188 -0
  219. data/doc/rdoc/classes/PlatformInfo.html +663 -159
  220. data/doc/rdoc/classes/RakeExtensions.html +4 -4
  221. data/doc/rdoc/classes/Signal.html +134 -0
  222. data/doc/rdoc/created.rid +1 -1
  223. data/doc/rdoc/files/DEVELOPERS_TXT.html +15 -10
  224. data/doc/rdoc/files/README.html +5 -7
  225. data/doc/rdoc/files/ext/{passenger → phusion_passenger}/native_support_c.html +2 -2
  226. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/abstract_request_handler_rb.html +7 -9
  227. data/doc/rdoc/files/lib/phusion_passenger/abstract_server_collection_rb.html +120 -0
  228. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/abstract_server_rb.html +7 -10
  229. data/doc/rdoc/files/lib/phusion_passenger/admin_tools/control_process_rb.html +99 -0
  230. data/doc/rdoc/files/lib/phusion_passenger/admin_tools_rb.html +92 -0
  231. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/application_rb.html +6 -8
  232. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/console_text_template_rb.html +5 -7
  233. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/constants_rb.html +4 -5
  234. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/dependencies_rb.html +6 -8
  235. data/doc/rdoc/files/lib/phusion_passenger/events_rb.html +116 -0
  236. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/exceptions_rb.html +5 -7
  237. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/html_template_rb.html +5 -7
  238. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/message_channel_rb.html +5 -7
  239. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/platform_info_rb.html +6 -7
  240. data/doc/rdoc/files/lib/phusion_passenger/rack/application_spawner_rb.html +123 -0
  241. data/doc/rdoc/files/lib/phusion_passenger/rack/request_handler_rb.html +117 -0
  242. data/doc/rdoc/files/lib/{passenger/utils_rb.html → phusion_passenger/railz/application_spawner_rb.html} +24 -17
  243. data/doc/rdoc/files/lib/phusion_passenger/railz/cgi_fixed_rb.html +126 -0
  244. data/doc/rdoc/files/lib/phusion_passenger/railz/framework_spawner_rb.html +139 -0
  245. data/doc/rdoc/files/lib/phusion_passenger/railz/request_handler_rb.html +118 -0
  246. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/simple_benchmarking_rb.html +5 -7
  247. data/doc/rdoc/files/lib/{passenger → phusion_passenger}/spawn_manager_rb.html +40 -24
  248. data/doc/rdoc/files/lib/phusion_passenger/utils_rb.html +169 -0
  249. data/doc/rdoc/files/lib/phusion_passenger/wsgi/application_spawner_rb.html +120 -0
  250. data/doc/rdoc/files/lib/rake/extensions_rb.html +3 -4
  251. data/doc/rdoc/fr_class_index.html +37 -19
  252. data/doc/rdoc/fr_file_index.html +25 -14
  253. data/doc/rdoc/fr_method_index.html +145 -74
  254. data/ext/apache2/Application.h +145 -44
  255. data/ext/apache2/ApplicationPool.h +27 -29
  256. data/ext/apache2/ApplicationPoolServer.h +183 -72
  257. data/ext/apache2/ApplicationPoolServerExecutable.cpp +249 -42
  258. data/ext/apache2/Bucket.cpp +61 -9
  259. data/ext/apache2/Bucket.h +15 -8
  260. data/ext/apache2/CachedFileStat.cpp +114 -0
  261. data/ext/apache2/CachedFileStat.h +169 -0
  262. data/ext/apache2/Configuration.cpp +213 -22
  263. data/ext/apache2/Configuration.h +176 -13
  264. data/ext/apache2/DirectoryMapper.h +287 -0
  265. data/ext/apache2/Exceptions.h +30 -12
  266. data/ext/apache2/FileChecker.h +108 -0
  267. data/ext/apache2/Hooks.cpp +709 -493
  268. data/ext/apache2/LICENSE-CNRI.TXT +15 -0
  269. data/ext/apache2/Logging.h +26 -22
  270. data/ext/apache2/MessageChannel.h +124 -15
  271. data/ext/apache2/PoolOptions.h +283 -0
  272. data/ext/apache2/SpawnManager.h +75 -99
  273. data/ext/apache2/StandardApplicationPool.h +296 -195
  274. data/ext/apache2/SystemTime.cpp +28 -0
  275. data/ext/apache2/SystemTime.h +82 -0
  276. data/ext/apache2/Utils.cpp +172 -18
  277. data/ext/apache2/Utils.h +124 -19
  278. data/ext/boost/cstdint.hpp +4 -2
  279. data/ext/boost/current_function.hpp +67 -0
  280. data/ext/boost/detail/sp_counted_base.hpp +4 -4
  281. data/ext/boost/thread/exceptions.hpp +2 -1
  282. data/ext/boost/thread/pthread/thread.hpp +11 -3
  283. data/ext/boost/thread/pthread/thread_data.hpp +2 -1
  284. data/ext/oxt/backtrace.cpp +172 -0
  285. data/ext/oxt/backtrace.hpp +135 -0
  286. data/ext/oxt/detail/backtrace_disabled.hpp +39 -0
  287. data/ext/oxt/detail/backtrace_enabled.hpp +155 -0
  288. data/ext/oxt/detail/spin_lock_gcc_x86.hpp +82 -0
  289. data/ext/oxt/detail/spin_lock_portable.hpp +38 -0
  290. data/ext/oxt/detail/spin_lock_pthreads.hpp +97 -0
  291. data/ext/oxt/detail/tracable_exception_disabled.hpp +46 -0
  292. data/ext/oxt/detail/tracable_exception_enabled.hpp +48 -0
  293. data/ext/oxt/macros.hpp +58 -0
  294. data/ext/oxt/spin_lock.hpp +55 -0
  295. data/ext/{apache2/System.cpp → oxt/system_calls.cpp} +87 -52
  296. data/ext/oxt/system_calls.hpp +234 -0
  297. data/ext/oxt/thread.cpp +32 -0
  298. data/ext/oxt/thread.hpp +223 -0
  299. data/ext/oxt/tracable_exception.cpp +87 -0
  300. data/ext/oxt/tracable_exception.hpp +35 -0
  301. data/{lib/passenger/constants.rb → ext/phusion_passenger/extconf.rb} +14 -9
  302. data/ext/{passenger → phusion_passenger}/native_support.c +33 -6
  303. data/lib/{passenger → phusion_passenger}/abstract_request_handler.rb +209 -93
  304. data/lib/{passenger → phusion_passenger}/abstract_server.rb +23 -8
  305. data/lib/phusion_passenger/abstract_server_collection.rb +301 -0
  306. data/lib/phusion_passenger/admin_tools.rb +25 -0
  307. data/lib/phusion_passenger/admin_tools/control_process.rb +107 -0
  308. data/lib/{passenger → phusion_passenger}/application.rb +13 -16
  309. data/lib/{passenger → phusion_passenger}/console_text_template.rb +2 -2
  310. data/{ext/passenger/extconf.rb → lib/phusion_passenger/constants.rb} +5 -5
  311. data/lib/{passenger → phusion_passenger}/dependencies.rb +38 -32
  312. data/lib/phusion_passenger/events.rb +45 -0
  313. data/lib/{passenger → phusion_passenger}/exceptions.rb +12 -5
  314. data/lib/{passenger → phusion_passenger}/html_template.rb +2 -2
  315. data/lib/{passenger → phusion_passenger}/message_channel.rb +3 -2
  316. data/lib/phusion_passenger/platform_info.rb +500 -0
  317. data/lib/{passenger → phusion_passenger}/rack/application_spawner.rb +29 -22
  318. data/lib/{passenger → phusion_passenger}/rack/request_handler.rb +14 -9
  319. data/lib/{passenger → phusion_passenger}/railz/application_spawner.rb +94 -74
  320. data/lib/{passenger → phusion_passenger}/railz/cgi_fixed.rb +2 -2
  321. data/lib/{passenger → phusion_passenger}/railz/framework_spawner.rb +86 -98
  322. data/lib/{passenger → phusion_passenger}/railz/request_handler.rb +6 -6
  323. data/lib/{passenger → phusion_passenger}/simple_benchmarking.rb +0 -0
  324. data/lib/{passenger → phusion_passenger}/spawn_manager.rb +136 -128
  325. data/lib/{passenger → phusion_passenger}/templates/apache2_config_snippets.txt.erb +0 -0
  326. data/lib/{passenger → phusion_passenger}/templates/apache_must_be_compiled_with_compatible_mpm.txt.erb +0 -0
  327. data/lib/phusion_passenger/templates/app_exited_during_initialization.html.erb +38 -0
  328. data/lib/{passenger → phusion_passenger}/templates/app_init_error.html.erb +0 -0
  329. data/lib/{passenger → phusion_passenger}/templates/database_error.html.erb +0 -0
  330. data/lib/{passenger → phusion_passenger}/templates/deployment_example.txt.erb +1 -1
  331. data/lib/{passenger → phusion_passenger}/templates/error_layout.css +0 -0
  332. data/lib/{passenger → phusion_passenger}/templates/error_layout.html.erb +0 -0
  333. data/lib/{passenger → phusion_passenger}/templates/framework_init_error.html.erb +0 -0
  334. data/lib/{passenger → phusion_passenger}/templates/general_error.html.erb +0 -0
  335. data/lib/{passenger → phusion_passenger}/templates/invalid_app_root.html.erb +1 -1
  336. data/lib/{passenger → phusion_passenger}/templates/load_error.html.erb +0 -0
  337. data/lib/{passenger → phusion_passenger}/templates/no_write_permission_to_passenger_root.txt.erb +0 -0
  338. data/lib/{passenger → phusion_passenger}/templates/possible_solutions_for_compilation_and_installation_problems.txt.erb +0 -0
  339. data/lib/{passenger → phusion_passenger}/templates/run_installer_as_root.txt.erb +0 -0
  340. data/lib/{passenger → phusion_passenger}/templates/version_not_found.html.erb +0 -0
  341. data/lib/{passenger → phusion_passenger}/templates/welcome.txt.erb +0 -0
  342. data/lib/{passenger → phusion_passenger}/utils.rb +210 -44
  343. data/lib/{passenger → phusion_passenger}/wsgi/application_spawner.rb +18 -15
  344. data/lib/{passenger → phusion_passenger}/wsgi/request_handler.py +7 -1
  345. data/man/passenger-memory-stats.8 +1 -1
  346. data/misc/render_error_pages.rb +1 -1
  347. data/test/ApplicationPoolServerTest.cpp +0 -28
  348. data/test/ApplicationPoolServer_ApplicationPoolTest.cpp +4 -0
  349. data/test/ApplicationPoolTest.cpp +307 -69
  350. data/test/CachedFileStatTest.cpp +262 -0
  351. data/test/FileCheckerTest.cpp +79 -0
  352. data/test/MessageChannelTest.cpp +3 -3
  353. data/test/PoolOptionsTest.cpp +37 -0
  354. data/test/SpawnManagerTest.cpp +4 -4
  355. data/test/StandardApplicationPoolTest.cpp +4 -0
  356. data/test/SystemTimeTest.cpp +37 -0
  357. data/test/UtilsTest.cpp +137 -0
  358. data/test/integration_tests.rb +270 -23
  359. data/test/oxt/backtrace_test.cpp +128 -0
  360. data/test/oxt/oxt_test_main.cpp +25 -0
  361. data/test/oxt/syscall_interruption_test.cpp +50 -0
  362. data/test/ruby/abstract_request_handler_spec.rb +83 -0
  363. data/test/ruby/abstract_server_collection_spec.rb +246 -0
  364. data/test/ruby/application_spec.rb +3 -3
  365. data/test/ruby/message_channel_spec.rb +2 -2
  366. data/test/ruby/rack/application_spawner_spec.rb +3 -5
  367. data/test/ruby/rails/application_spawner_spec.rb +54 -15
  368. data/test/ruby/rails/framework_spawner_spec.rb +6 -8
  369. data/test/ruby/rails/minimal_spawner_spec.rb +29 -0
  370. data/test/ruby/rails/spawner_error_handling_spec.rb +1 -1
  371. data/test/ruby/rails/spawner_privilege_lowering_spec.rb +3 -3
  372. data/test/ruby/spawn_manager_spec.rb +23 -12
  373. data/test/ruby/utils_spec.rb +36 -2
  374. data/test/ruby/wsgi/application_spawner_spec.rb +47 -0
  375. data/test/stub/apache2/httpd.conf.erb +3 -5
  376. data/test/stub/message_channel.rb +2 -2
  377. data/test/stub/message_channel_2.rb +2 -2
  378. data/test/stub/message_channel_3.rb +3 -3
  379. data/test/stub/minimal-railsapp/README +0 -0
  380. data/test/stub/minimal-railsapp/config/application.rb +0 -0
  381. data/test/stub/minimal-railsapp/config/environment.rb +0 -0
  382. data/test/stub/minimal-railsapp/vendor/rails/actionmailer/lib/action_mailer.rb +0 -0
  383. data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_controller.rb +0 -0
  384. data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_pack.rb +0 -0
  385. data/test/stub/minimal-railsapp/vendor/rails/actionpack/lib/action_view.rb +0 -0
  386. data/test/stub/minimal-railsapp/vendor/rails/activerecord/lib/active_record.rb +0 -0
  387. data/test/stub/minimal-railsapp/vendor/rails/activeresource/lib/active_resource.rb +0 -0
  388. data/test/stub/minimal-railsapp/vendor/rails/activesupport/lib/active_support.rb +0 -0
  389. data/test/stub/minimal-railsapp/vendor/rails/activesupport/lib/active_support/whiny_nil.rb +0 -0
  390. data/test/stub/minimal-railsapp/vendor/rails/railties/lib/dispatcher.rb +0 -0
  391. data/test/stub/minimal-railsapp/vendor/rails/railties/lib/initializer.rb +0 -0
  392. data/test/stub/minimal-railsapp/vendor/rails/railties/lib/ruby_version_check.rb +0 -0
  393. data/test/stub/rails_apps/foobar/app/controllers/foo_controller.rb +8 -0
  394. data/test/stub/rails_apps/foobar/config/environments/development.rb +1 -2
  395. data/test/stub/rails_apps/mycook/app/controllers/welcome_controller.rb +21 -1
  396. data/test/stub/rails_apps/mycook/sites/some.site/public/uploads.html +26 -0
  397. data/test/stub/rails_apps/mycook/sites/some.site/public/welcome/cached.html +26 -0
  398. data/test/stub/railsapp/app/controllers/application.rb +0 -0
  399. data/test/stub/railsapp/app/controllers/bar_controller_1.rb +0 -0
  400. data/test/stub/railsapp/app/controllers/bar_controller_2.rb +1 -1
  401. data/test/stub/railsapp/app/controllers/foo_controller.rb +4 -0
  402. data/test/stub/railsapp/app/helpers/application_helper.rb +0 -0
  403. data/test/stub/railsapp/config/boot.rb +0 -0
  404. data/test/stub/railsapp/config/database.yml +0 -0
  405. data/test/stub/railsapp/config/environment.rb +0 -0
  406. data/test/stub/railsapp/config/environments/development.rb +0 -0
  407. data/test/stub/railsapp/config/environments/production.rb +0 -0
  408. data/test/stub/railsapp/config/initializers/inflections.rb +0 -0
  409. data/test/stub/railsapp/config/initializers/mime_types.rb +0 -0
  410. data/test/stub/railsapp/config/routes.rb +0 -0
  411. data/test/stub/railsapp/public/useless.txt +0 -0
  412. data/test/stub/spawn_server.rb +3 -4
  413. data/test/stub/wsgi/passenger_wsgi.pyc +0 -0
  414. data/test/support/apache2_controller.rb +57 -7
  415. data/test/support/tut.h +15 -0
  416. data/vendor/README +12 -0
  417. data/vendor/README_FOR_PACKAGERS +1 -0
  418. data/vendor/rack-0.9.1/AUTHORS +8 -0
  419. data/vendor/rack-0.9.1/COPYING +18 -0
  420. data/vendor/rack-0.9.1/ChangeLog +1423 -0
  421. data/vendor/rack-0.9.1/KNOWN-ISSUES +18 -0
  422. data/vendor/rack-0.9.1/README +306 -0
  423. data/vendor/rack-0.9.1/Rakefile +188 -0
  424. data/vendor/rack-0.9.1/SPEC +129 -0
  425. data/vendor/rack-0.9.1/lib/rack.rb +86 -0
  426. data/vendor/rack-0.9.1/lib/rack/adapter/camping.rb +22 -0
  427. data/vendor/rack-0.9.1/lib/rack/auth/abstract/handler.rb +28 -0
  428. data/vendor/rack-0.9.1/lib/rack/auth/abstract/request.rb +37 -0
  429. data/vendor/rack-0.9.1/lib/rack/auth/basic.rb +58 -0
  430. data/vendor/rack-0.9.1/lib/rack/auth/digest/md5.rb +124 -0
  431. data/vendor/rack-0.9.1/lib/rack/auth/digest/nonce.rb +51 -0
  432. data/vendor/rack-0.9.1/lib/rack/auth/digest/params.rb +55 -0
  433. data/vendor/rack-0.9.1/lib/rack/auth/digest/request.rb +40 -0
  434. data/vendor/rack-0.9.1/lib/rack/auth/openid.rb +438 -0
  435. data/vendor/rack-0.9.1/lib/rack/builder.rb +67 -0
  436. data/vendor/rack-0.9.1/lib/rack/cascade.rb +36 -0
  437. data/vendor/rack-0.9.1/lib/rack/commonlogger.rb +61 -0
  438. data/vendor/rack-0.9.1/lib/rack/conditionalget.rb +43 -0
  439. data/vendor/rack-0.9.1/lib/rack/content_length.rb +25 -0
  440. data/vendor/rack-0.9.1/lib/rack/deflater.rb +87 -0
  441. data/vendor/rack-0.9.1/lib/rack/directory.rb +150 -0
  442. data/vendor/rack-0.9.1/lib/rack/file.rb +85 -0
  443. data/vendor/rack-0.9.1/lib/rack/handler.rb +48 -0
  444. data/vendor/rack-0.9.1/lib/rack/handler/cgi.rb +57 -0
  445. data/vendor/rack-0.9.1/lib/rack/handler/evented_mongrel.rb +8 -0
  446. data/vendor/rack-0.9.1/lib/rack/handler/fastcgi.rb +86 -0
  447. data/vendor/rack-0.9.1/lib/rack/handler/lsws.rb +52 -0
  448. data/vendor/rack-0.9.1/lib/rack/handler/mongrel.rb +82 -0
  449. data/vendor/rack-0.9.1/lib/rack/handler/scgi.rb +57 -0
  450. data/vendor/rack-0.9.1/lib/rack/handler/swiftiplied_mongrel.rb +8 -0
  451. data/vendor/rack-0.9.1/lib/rack/handler/thin.rb +15 -0
  452. data/vendor/rack-0.9.1/lib/rack/handler/webrick.rb +61 -0
  453. data/vendor/rack-0.9.1/lib/rack/head.rb +19 -0
  454. data/vendor/rack-0.9.1/lib/rack/lint.rb +465 -0
  455. data/vendor/rack-0.9.1/lib/rack/lobster.rb +65 -0
  456. data/vendor/rack-0.9.1/lib/rack/methodoverride.rb +27 -0
  457. data/vendor/rack-0.9.1/lib/rack/mime.rb +204 -0
  458. data/vendor/rack-0.9.1/lib/rack/mock.rb +160 -0
  459. data/vendor/rack-0.9.1/lib/rack/recursive.rb +57 -0
  460. data/vendor/rack-0.9.1/lib/rack/reloader.rb +64 -0
  461. data/vendor/rack-0.9.1/lib/rack/request.rb +218 -0
  462. data/vendor/rack-0.9.1/lib/rack/response.rb +171 -0
  463. data/vendor/rack-0.9.1/lib/rack/session/abstract/id.rb +153 -0
  464. data/vendor/rack-0.9.1/lib/rack/session/cookie.rb +89 -0
  465. data/vendor/rack-0.9.1/lib/rack/session/memcache.rb +97 -0
  466. data/vendor/rack-0.9.1/lib/rack/session/pool.rb +73 -0
  467. data/vendor/rack-0.9.1/lib/rack/showexceptions.rb +348 -0
  468. data/vendor/rack-0.9.1/lib/rack/showstatus.rb +106 -0
  469. data/vendor/rack-0.9.1/lib/rack/static.rb +38 -0
  470. data/vendor/rack-0.9.1/lib/rack/urlmap.rb +48 -0
  471. data/vendor/rack-0.9.1/lib/rack/utils.rb +347 -0
  472. metadata +1197 -1055
  473. data/doc/cxxapi/System_8h-source.html +0 -251
  474. data/doc/cxxapi/classDirectoryMapper-members.html +0 -38
  475. data/doc/cxxapi/classDirectoryMapper.html +0 -203
  476. data/doc/cxxapi/classPassenger_1_1Thread.html +0 -100
  477. data/doc/cxxapi/classboost_1_1this__thread_1_1disable__syscall__interruption.html +0 -46
  478. data/doc/cxxapi/classboost_1_1this__thread_1_1restore__syscall__interruption-members.html +0 -33
  479. data/doc/cxxapi/classboost_1_1this__thread_1_1restore__syscall__interruption.html +0 -44
  480. data/doc/cxxapi/namespacePassenger.html +0 -208
  481. data/doc/cxxapi/namespacePassenger_1_1InterruptableCalls.html +0 -43
  482. data/doc/cxxapi/namespacemembers.html +0 -70
  483. data/doc/cxxapi/namespacemembers_func.html +0 -66
  484. data/doc/cxxapi/namespacemembers_type.html +0 -46
  485. data/doc/cxxapi/namespaces.html +0 -35
  486. data/doc/rdoc/classes/Passenger.html +0 -136
  487. data/doc/rdoc/classes/Passenger/AbstractRequestHandler.html +0 -402
  488. data/doc/rdoc/classes/Passenger/SpawnManager.html +0 -379
  489. data/doc/rdoc/classes/Passenger/Utils.html +0 -578
  490. data/ext/apache2/System.h +0 -228
  491. data/lib/passenger/platform_info.rb +0 -302
  492. data/lib/passenger/templates/app_exited_during_initialization.html.erb +0 -19
  493. data/test/stub/apache2/httpd.conf +0 -75
  494. data/test/stub/rails_apps/foobar/config/environments/test.rb +0 -22
  495. data/test/stub/rails_apps/mycook/config/environments/test.rb +0 -22
  496. data/test/stub/railsapp/config/environments/test.rb +0 -22
  497. data/test/stub/railsapp2/config/environments/test.rb +0 -22
@@ -3,7 +3,8 @@
3
3
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
4
4
  <head>
5
5
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
- <meta name="generator" content="AsciiDoc 8.2.7" />
6
+ <meta name="generator" content="AsciiDoc 8.3.4" />
7
+ <title>Phusion Passenger users guide</title>
7
8
  <style type="text/css">
8
9
  /* Debug borders */
9
10
  p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
@@ -110,7 +111,10 @@ div#footer-badges {
110
111
  padding-bottom: 0.5em;
111
112
  }
112
113
 
113
- div#preamble,
114
+ div#preamble {
115
+ margin-top: 1.5em;
116
+ margin-bottom: 1.5em;
117
+ }
114
118
  div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
115
119
  div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
116
120
  div.admonitionblock {
@@ -218,6 +222,7 @@ dt {
218
222
  margin-top: 0.5em;
219
223
  margin-bottom: 0;
220
224
  font-style: normal;
225
+ color: navy;
221
226
  }
222
227
  dd > *:first-child {
223
228
  margin-top: 0.1em;
@@ -226,12 +231,28 @@ dd > *:first-child {
226
231
  ul, ol {
227
232
  list-style-position: outside;
228
233
  }
229
- div.olist > ol {
234
+ ol.arabic {
230
235
  list-style-type: decimal;
231
236
  }
232
- div.olist2 > ol {
237
+ ol.loweralpha {
233
238
  list-style-type: lower-alpha;
234
239
  }
240
+ ol.upperalpha {
241
+ list-style-type: upper-alpha;
242
+ }
243
+ ol.lowerroman {
244
+ list-style-type: lower-roman;
245
+ }
246
+ ol.upperroman {
247
+ list-style-type: upper-roman;
248
+ }
249
+
250
+ div.compact ul, div.compact ol,
251
+ div.compact p, div.compact p,
252
+ div.compact div, div.compact div {
253
+ margin-top: 0.1em;
254
+ margin-bottom: 0.1em;
255
+ }
235
256
 
236
257
  div.tableblock > table {
237
258
  border: 3px solid #527bbd;
@@ -243,22 +264,53 @@ thead {
243
264
  tfoot {
244
265
  font-weight: bold;
245
266
  }
267
+ td > div.verse {
268
+ white-space: pre;
269
+ }
270
+ p.table {
271
+ margin-top: 0;
272
+ }
273
+ /* Because the table frame attribute is overriden by CSS in most browsers. */
274
+ div.tableblock > table[frame="void"] {
275
+ border-style: none;
276
+ }
277
+ div.tableblock > table[frame="hsides"] {
278
+ border-left-style: none;
279
+ border-right-style: none;
280
+ }
281
+ div.tableblock > table[frame="vsides"] {
282
+ border-top-style: none;
283
+ border-bottom-style: none;
284
+ }
285
+
246
286
 
247
- div.hlist {
287
+ div.hdlist {
248
288
  margin-top: 0.8em;
249
289
  margin-bottom: 0.8em;
250
290
  }
251
- div.hlist td {
291
+ div.hdlist tr {
252
292
  padding-bottom: 15px;
253
293
  }
254
- td.hlist1 {
294
+ dt.hdlist1.strong, td.hdlist1.strong {
295
+ font-weight: bold;
296
+ }
297
+ td.hdlist1 {
255
298
  vertical-align: top;
256
299
  font-style: normal;
257
300
  padding-right: 0.8em;
301
+ color: navy;
258
302
  }
259
- td.hlist2 {
303
+ td.hdlist2 {
260
304
  vertical-align: top;
261
305
  }
306
+ div.hdlist.compact tr {
307
+ margin: 0;
308
+ padding-bottom: 0;
309
+ }
310
+
311
+ .comment {
312
+ background: yellow;
313
+ }
262
314
 
263
315
  @media print {
264
316
  div#footer-badges { display: none; }
@@ -330,14 +382,6 @@ div.exampleblock-content {
330
382
 
331
383
  /* IE6 sets dynamically generated links as visited. */
332
384
  div#toc a:visited { color: blue; }
333
-
334
- /* Because IE6 child selector is broken. */
335
- div.olist2 ol {
336
- list-style-type: lower-alpha;
337
- }
338
- div.olist2 div.olist ol {
339
- list-style-type: decimal;
340
- }
341
385
  </style>
342
386
  <script type="text/javascript">
343
387
  /*<![CDATA[*/
@@ -413,7 +457,6 @@ function generateToc(toclevels) {
413
457
  }
414
458
  /*]]>*/
415
459
  </script>
416
- <title>Phusion Passenger users guide</title>
417
460
  </head>
418
461
  <body>
419
462
  <div id="header">
@@ -425,17 +468,17 @@ function generateToc(toclevels) {
425
468
  </div>
426
469
  <div id="preamble">
427
470
  <div class="sectionbody">
428
- <div class="para"><p><span class="image">
471
+ <div class="paragraph"><p><span class="image">
429
472
  <a class="image" href="http://www.phusion.nl/">
430
473
  <img src="images/phusion_banner.png" alt="images/phusion_banner.png" />
431
474
  </a>
432
475
  </span></p></div>
433
- <div class="para"><p>Phusion Passenger is an Apache module, which makes deploying Ruby and Ruby on
476
+ <div class="paragraph"><p>Phusion Passenger is an Apache module, which makes deploying Ruby and Ruby on
434
477
  Rails applications on Apache a breeze. It follows the usual Ruby on Rails
435
- conventions, such as "Don't-Repeat-Yourself" and ease of setup, while at the
478
+ conventions, such as "Don&#8217;t-Repeat-Yourself" and ease of setup, while at the
436
479
  same time providing enough flexibility.</p></div>
437
- <div class="para"><p>This users guide will teach you:</p></div>
438
- <div class="ilist"><ul>
480
+ <div class="paragraph"><p>This users guide will teach you:</p></div>
481
+ <div class="ulist"><ul>
439
482
  <li>
440
483
  <p>
441
484
  How to install Phusion Passenger.
@@ -462,16 +505,16 @@ How to solve common problems.
462
505
  </p>
463
506
  </li>
464
507
  </ul></div>
465
- <div class="para"><p>This guide assumes that the reader is somewhat familiar with Apache and with
508
+ <div class="paragraph"><p>This guide assumes that the reader is somewhat familiar with Apache and with
466
509
  using the commandline.</p></div>
467
510
  </div>
468
511
  </div>
469
512
  <h2 id="_supported_operating_systems">1. Supported operating systems</h2>
470
513
  <div class="sectionbody">
471
- <div class="para"><p>Phusion Passenger works on any POSIX-compliant operating system. In other
514
+ <div class="paragraph"><p>Phusion Passenger works on any POSIX-compliant operating system. In other
472
515
  words: practically any operating system on earth, except Microsoft Windows.</p></div>
473
- <div class="para"><p>Phusion Passenger has been tested on:</p></div>
474
- <div class="ilist"><ul>
516
+ <div class="paragraph"><p>Phusion Passenger has been tested on:</p></div>
517
+ <div class="ulist"><ul>
475
518
  <li>
476
519
  <p>
477
520
  Ubuntu Linux 6.06 (x86)
@@ -484,6 +527,11 @@ Ubuntu Linux 7.10 (x86)
484
527
  </li>
485
528
  <li>
486
529
  <p>
530
+ Ubuntu Linux 8.04 (x86)
531
+ </p>
532
+ </li>
533
+ <li>
534
+ <p>
487
535
  Debian Sarge (x86)
488
536
  </p>
489
537
  </li>
@@ -528,19 +576,19 @@ MacOS X Leopard (x86)
528
576
  </p>
529
577
  </li>
530
578
  </ul></div>
531
- <div class="para"><p>Other operating systems have not been tested, but Phusion Passenger will probably
579
+ <div class="paragraph"><p>Other operating systems have not been tested, but Phusion Passenger will probably
532
580
  work fine on them. Please
533
581
  <a href="http://code.google.com/p/phusion-passenger/issues/list">report a bug</a>
534
582
  or
535
583
  <a href="http://groups.google.com/group/phusion-passenger">join our discussion list</a>
536
- if it doesn't.</p></div>
584
+ if it doesn&#8217;t.</p></div>
537
585
  </div>
538
586
  <h2 id="_installing_phusion_passenger">2. Installing Phusion Passenger</h2>
539
587
  <div class="sectionbody">
540
588
  <h3 id="_generic_installation_instructions">2.1. Generic installation instructions</h3><div style="clear:left"></div>
541
589
  <h4 id="install_passenger">2.1.1. Overview of download and installation methods</h4>
542
- <div class="para"><p>There are two ways to install Phusion Passenger:</p></div>
543
- <div class="olist"><ol>
590
+ <div class="paragraph"><p>There are two ways to install Phusion Passenger:</p></div>
591
+ <div class="olist arabic"><ol class="arabic">
544
592
  <li>
545
593
  <p>
546
594
  By installing the Phusion Passenger gem, as instructed on the
@@ -561,8 +609,8 @@ By downloading the source tarball from the Phusion Passenger website
561
609
  </p>
562
610
  </li>
563
611
  </ol></div>
564
- <div class="para"><p>In our opinion, installing the gem or the native package is easiest.</p></div>
565
- <div class="para"><p>Phusion Passenger provides an easy-to-use installer for installing the Phusion
612
+ <div class="paragraph"><p>In our opinion, installing the gem or the native package is easiest.</p></div>
613
+ <div class="paragraph"><p>Phusion Passenger provides an easy-to-use installer for installing the Phusion
566
614
  Passenger Apache module (<em>mod_passenger</em>).</p></div>
567
615
  <div class="admonitionblock">
568
616
  <table><tr>
@@ -580,16 +628,16 @@ you.</td>
580
628
  <td class="icon">
581
629
  <img src="./images/icons/note.png" alt="Note" />
582
630
  </td>
583
- <td class="content">You can skip this section if you've installed Phusion Passenger via a
631
+ <td class="content">You can skip this section if you&#8217;ve installed Phusion Passenger via a
584
632
  native Linux package, because no compilation is necessary.</td>
585
633
  </tr></table>
586
634
  </div>
587
- <div class="para"><p>If your system has multiple Apache installations (this is likely the case on
635
+ <div class="paragraph"><p>If your system has multiple Apache installations (this is likely the case on
588
636
  MacOS X), then you will need to tell the Phusion Passenger installer which one
589
637
  to use. If you only have one Apache installation (the case on most Linux
590
638
  systems), then you can skip this section because Phusion Passenger will
591
639
  automatically detect it.</p></div>
592
- <div class="para"><p>Every Apache installation has its own <tt>apxs</tt> program. You will need to tell
640
+ <div class="paragraph"><p>Every Apache installation has its own <tt>apxs</tt> program. You will need to tell
593
641
  Phusion Passenger the location of this program, by specifying the <tt>APXS2</tt>
594
642
  environment variable. Suppose that you want to use the Apache installation in
595
643
  <em>/opt/apache2</em>. Then, assuming that the corresponding <tt>apxs</tt> program is located
@@ -613,18 +661,18 @@ be located in the <tt>sbin</tt> folder instead of the <tt>bin</tt> folder.</td>
613
661
  <td class="icon">
614
662
  <img src="./images/icons/note.png" alt="Note" />
615
663
  </td>
616
- <td class="content">You can skip this section if you've installed Phusion Passenger via a
664
+ <td class="content">You can skip this section if you&#8217;ve installed Phusion Passenger via a
617
665
  native Linux package, because no compilation is necessary.</td>
618
666
  </tr></table>
619
667
  </div>
620
- <div class="para"><p>If your system has multiple Ruby installations (this is likely the case on
668
+ <div class="paragraph"><p>If your system has multiple Ruby installations (this is likely the case on
621
669
  MacOS X), then you will need to tell the Phusion Passenger installer which one
622
670
  to use. If you only have one Ruby installation (the case on most Linux systems),
623
671
  then you can skip this section because Phusion Passenger will automatically detect it.</p></div>
624
- <div class="para"><p>To specify the Ruby installation, prepend your Ruby installation's <tt>bin</tt>
672
+ <div class="paragraph"><p>To specify the Ruby installation, prepend your Ruby installation&#8217;s <tt>bin</tt>
625
673
  directory to the <tt>PATH</tt> environment variable. For example, if you have the
626
674
  following Ruby installations:</p></div>
627
- <div class="ilist"><ul>
675
+ <div class="ulist"><ul>
628
676
  <li>
629
677
  <p>
630
678
  /usr/bin/ruby
@@ -636,44 +684,32 @@ following Ruby installations:</p></div>
636
684
  </p>
637
685
  </li>
638
686
  </ul></div>
639
- <div class="para"><p>and you want to use the latter, then type:</p></div>
687
+ <div class="paragraph"><p>and you want to use the latter, then type:</p></div>
640
688
  <div class="listingblock">
641
689
  <div class="content">
642
690
  <pre><tt>export PATH=/opt/myruby/bin:$PATH</tt></pre>
643
691
  </div></div>
644
692
  <h4 id="_installing_via_the_gem">2.1.4. Installing via the gem</h4>
645
- <div class="para"><p>Please install the gem and then run the Phusion Passenger installer, by typing the
693
+ <div class="paragraph"><p>Please install the gem and then run the Phusion Passenger installer, by typing the
646
694
  following commands:</p></div>
647
695
  <div class="listingblock">
648
696
  <div class="content">
649
697
  <pre><tt>gem install passenger-x.x.x.gem
650
698
  passenger-install-apache2-module</tt></pre>
651
699
  </div></div>
652
- <div class="para"><p>Please follow the instructions given by the installer.</p></div>
700
+ <div class="paragraph"><p>Please follow the instructions given by the installer.</p></div>
653
701
  <h4 id="_installing_via_a_native_linux_package">2.1.5. Installing via a native Linux package</h4>
654
- <div class="para"><p>Please install the native Linux package, e.g.:</p></div>
702
+ <div class="paragraph"><p>John Leach from Brightbox has kindly provided an Ubuntu Hardy package for Phusion Passenger. The package is available from the <a href="http://apt.brightbox.net">Brightbox repository</a>.</p></div>
703
+ <div class="paragraph"><p>Please install the native Linux package, e.g.:</p></div>
655
704
  <div class="listingblock">
656
705
  <div class="content">
657
- <pre><tt>gdebi passenger_x.x.x-i386.deb</tt></pre>
706
+ <pre><tt>sudo sh -c 'echo "deb http://apt.brightbox.net hardy main" &gt; /etc/apt/sources.list.d/brightbox.list'
707
+ sudo sh -c 'wget -q -O - http://apt.brightbox.net/release.asc | apt-key add -'
708
+ sudo apt-get update
709
+ sudo apt-get install libapache2-mod-passenger</tt></pre>
658
710
  </div></div>
659
- <div class="para"><p>Next, you'll need to configure Apache. Run the "installer", as it will tell you
660
- the correct configuration options for Apache:</p></div>
661
- <div class="listingblock">
662
- <div class="content">
663
- <pre><tt>passenger-install-apache2-module</tt></pre>
664
- </div></div>
665
- <div class="admonitionblock">
666
- <table><tr>
667
- <td class="icon">
668
- <img src="./images/icons/note.png" alt="Note" />
669
- </td>
670
- <td class="content">The installer doesn't actually install anything because it will automatically
671
- detect that Phusion Passenger has already been installed. The only thing the
672
- installer will do in this case, is showing the correct Apache configurations.</td>
673
- </tr></table>
674
- </div>
675
711
  <h4 id="_installing_via_the_source_tarball">2.1.6. Installing via the source tarball</h4>
676
- <div class="para"><p>Extract the tarball to whatever location you prefer. The Phusion Passenger files
712
+ <div class="paragraph"><p>Extract the tarball to whatever location you prefer. The Phusion Passenger files
677
713
  are to reside in that location permanently. For example, if you would like
678
714
  Phusion Passenger to reside in <tt>/opt/passenger-x.x.x</tt>:</p></div>
679
715
  <div class="listingblock">
@@ -681,12 +717,12 @@ Phusion Passenger to reside in <tt>/opt/passenger-x.x.x</tt>:</p></div>
681
717
  <pre><tt>cd /opt
682
718
  tar xzvf ~/YourDownloadsFolder/passenger-x.x.x.tar.gz</tt></pre>
683
719
  </div></div>
684
- <div class="para"><p>Next, run the included installer:</p></div>
720
+ <div class="paragraph"><p>Next, run the included installer:</p></div>
685
721
  <div class="listingblock">
686
722
  <div class="content">
687
723
  <pre><tt>/opt/passenger-x.x.x/bin/passenger-install-apache2-module</tt></pre>
688
724
  </div></div>
689
- <div class="para"><p>Please follow the instructions given by the installer.</p></div>
725
+ <div class="paragraph"><p>Please follow the instructions given by the installer.</p></div>
690
726
  <div class="admonitionblock">
691
727
  <table><tr>
692
728
  <td class="icon">
@@ -698,17 +734,17 @@ installation. Furthermore, the <em>passenger-x.x.x</em> folder must be accessibl
698
734
  </div>
699
735
  <h3 id="_operating_system_specific_instructions_and_information">2.2. Operating system-specific instructions and information</h3><div style="clear:left"></div>
700
736
  <h4 id="_macos_x">2.2.1. MacOS X</h4>
701
- <div class="para"><p>Ben Ruebenstein has written an excellent
737
+ <div class="paragraph"><p>Ben Ruebenstein has written an excellent
702
738
  <a href="http://benr75.com/articles/2008/04/12/setup-mod_rails-phusion-mac-os-x-leopard">tutorial
703
739
  on installing Phusion Passenger on OS X</a>.</p></div>
704
740
  <h4 id="_ubuntu_linux">2.2.2. Ubuntu Linux</h4>
705
- <div class="para"><p>Ben Hughes has written an <a href="http://www.railsgarden.com/2008/04/12/configurating-passenger-mod_rails-on-slicehost-with-ubuntu-710/">article on installing Phusion Passenger on Ubuntu</a>.</p></div>
741
+ <div class="paragraph"><p>Ben Hughes has written an <a href="http://www.railsgarden.com/2008/04/12/configurating-passenger-mod_rails-on-slicehost-with-ubuntu-710/">article on installing Phusion Passenger on Ubuntu</a>.</p></div>
706
742
  </div>
707
743
  <h2 id="_deploying_a_ruby_on_rails_application">3. Deploying a Ruby on Rails application</h2>
708
744
  <div class="sectionbody">
709
- <div class="para"><p>Suppose you have a Ruby on Rails application in <em>/webapps/mycook</em>, and you own
745
+ <div class="paragraph"><p>Suppose you have a Ruby on Rails application in <em>/webapps/mycook</em>, and you own
710
746
  the domain <em>www.mycook.com</em>. You can either deploy your application to the
711
- virtual host's root (i.e. the application will be accessible from the root URL,
747
+ virtual host&#8217;s root (i.e. the application will be accessible from the root URL,
712
748
  <em>http://www.mycook.com/</em>), or in a sub URI (i.e. the application will be
713
749
  accessible from a sub URL, such as <em>http://www.mycook.com/railsapplication</em>).</p></div>
714
750
  <div class="admonitionblock">
@@ -721,9 +757,9 @@ are run, is &#8220;production&#8221;. You can change this by changing the
721
757
  <a href="#rails_env"><em>RailsEnv</em></a> configuration option.</td>
722
758
  </tr></table>
723
759
  </div>
724
- <h3 id="_deploying_to_a_virtual_host_s_root">3.1. Deploying to a virtual host's root</h3><div style="clear:left"></div>
725
- <div class="para"><p>Add a virtual host entry to your Apache configuration file. The virtual host's
726
- document root must point to your Ruby on Rails application's <em>public</em> folder.
760
+ <h3 id="_deploying_to_a_virtual_host_8217_s_root">3.1. Deploying to a virtual host&#8217;s root</h3><div style="clear:left"></div>
761
+ <div class="paragraph"><p>Add a virtual host entry to your Apache configuration file. The virtual host&#8217;s
762
+ document root must point to your Ruby on Rails application&#8217;s <em>public</em> folder.
727
763
  For example:</p></div>
728
764
  <div class="listingblock">
729
765
  <div class="content">
@@ -732,9 +768,9 @@ For example:</p></div>
732
768
  DocumentRoot /webapps/mycook/public
733
769
  &lt;/VirtualHost&gt;</tt></pre>
734
770
  </div></div>
735
- <div class="para"><p>Then restart Apache. The application has now been deployed.</p></div>
771
+ <div class="paragraph"><p>Then restart Apache. The application has now been deployed.</p></div>
736
772
  <h3 id="deploying_rails_to_sub_uri">3.2. Deploying to a sub URI</h3><div style="clear:left"></div>
737
- <div class="para"><p>Suppose that you already have a virtual host:</p></div>
773
+ <div class="paragraph"><p>Suppose that you already have a virtual host:</p></div>
738
774
  <div class="listingblock">
739
775
  <div class="content">
740
776
  <pre><tt>&lt;VirtualHost *:80&gt;
@@ -742,15 +778,15 @@ For example:</p></div>
742
778
  DocumentRoot /websites/phusion
743
779
  &lt;/VirtualHost&gt;</tt></pre>
744
780
  </div></div>
745
- <div class="para"><p>And you want your Ruby on Rails application to be accessible from the URL
781
+ <div class="paragraph"><p>And you want your Ruby on Rails application to be accessible from the URL
746
782
  <em>http://www.phusion.nl/rails</em>.</p></div>
747
- <div class="para"><p>To do this, make a symlink from your Ruby on Rails application's <em>public</em>
783
+ <div class="paragraph"><p>To do this, make a symlink from your Ruby on Rails application&#8217;s <em>public</em>
748
784
  folder to a directory in the document root. For example:</p></div>
749
785
  <div class="listingblock">
750
786
  <div class="content">
751
787
  <pre><tt>ln -s /webapps/mycook/public /websites/phusion/rails</tt></pre>
752
788
  </div></div>
753
- <div class="para"><p>Next, add a <a href="#RailsBaseURI">RailsBaseURI</a> option to the virtual host configuration:</p></div>
789
+ <div class="paragraph"><p>Next, add a <a href="#RailsBaseURI">RailsBaseURI</a> option to the virtual host configuration:</p></div>
754
790
  <div class="listingblock">
755
791
  <div class="content">
756
792
  <pre><tt>&lt;VirtualHost *:80&gt;
@@ -759,14 +795,14 @@ folder to a directory in the document root. For example:</p></div>
759
795
  RailsBaseURI /rails # This line has been added.
760
796
  &lt;/VirtualHost&gt;</tt></pre>
761
797
  </div></div>
762
- <div class="para"><p>Then restart Apache. The application has now been deployed.</p></div>
798
+ <div class="paragraph"><p>Then restart Apache. The application has now been deployed.</p></div>
763
799
  <div class="admonitionblock">
764
800
  <table><tr>
765
801
  <td class="icon">
766
802
  <img src="./images/icons/tip.png" alt="Tip" />
767
803
  </td>
768
804
  <td class="content">
769
- <div class="para"><p>You can deploy multiple Rails applications under a virtual host, by specifying
805
+ <div class="paragraph"><p>You can deploy multiple Rails applications under a virtual host, by specifying
770
806
  <a href="#RailsBaseURI">RailsBaseURI</a> multiple times. For example:</p></div>
771
807
  <div class="listingblock">
772
808
  <div class="content">
@@ -781,10 +817,10 @@ folder to a directory in the document root. For example:</p></div>
781
817
  </tr></table>
782
818
  </div>
783
819
  <h3 id="_redeploying_restarting_the_ruby_on_rails_application">3.3. Redeploying (restarting the Ruby on Rails application)</h3><div style="clear:left"></div>
784
- <div class="para"><p>Deploying a new version of a Ruby on Rails application is as simple as
820
+ <div class="paragraph"><p>Deploying a new version of a Ruby on Rails application is as simple as
785
821
  re-uploading the application files, and restarting the application.</p></div>
786
- <div class="para"><p>There are two ways to restart the application:</p></div>
787
- <div class="olist"><ol>
822
+ <div class="paragraph"><p>There are two ways to restart the application:</p></div>
823
+ <div class="olist arabic"><ol class="arabic">
788
824
  <li>
789
825
  <p>
790
826
  By restarting Apache.
@@ -793,33 +829,33 @@ By restarting Apache.
793
829
  <li>
794
830
  <p>
795
831
  By creating or modifying the file <em>tmp/restart.txt</em> in the Rails
796
- application's root folder. Phusion Passenger will automatically
797
- restart the application.
832
+ application&#8217;s <a href="#application_root">root folder</a>. Phusion Passenger will
833
+ automatically restart the application.
798
834
  </p>
799
835
  </li>
800
836
  </ol></div>
801
- <div class="para"><p>For example, to restart our example MyCook application, we type this in the
837
+ <div class="paragraph"><p>For example, to restart our example MyCook application, we type this in the
802
838
  command line:</p></div>
803
839
  <div class="listingblock">
804
840
  <div class="content">
805
841
  <pre><tt>touch /webapps/mycook/tmp/restart.txt</tt></pre>
806
842
  </div></div>
807
843
  <h3 id="_migrations">3.4. Migrations</h3><div style="clear:left"></div>
808
- <div class="para"><p>Phusion Passenger is not related to Ruby on Rails migrations in any way. To
844
+ <div class="paragraph"><p>Phusion Passenger is not related to Ruby on Rails migrations in any way. To
809
845
  run migrations on your deployment server, please login to your deployment
810
846
  server (e.g. with <em>ssh</em>) and type <tt>rake db:migrate RAILS_ENV=production</tt> in
811
847
  a shell console, just like one would normally run migrations.</p></div>
812
848
  <h3 id="_capistrano_integration">3.5. Capistrano integration</h3><div style="clear:left"></div>
813
- <div class="para"><p>See <a href="#capistrano">Capistrano recipe</a>.</p></div>
849
+ <div class="paragraph"><p>See <a href="#capistrano">Capistrano recipe</a>.</p></div>
814
850
  </div>
815
851
  <h2 id="_deploying_a_rack_based_ruby_application">4. Deploying a Rack-based Ruby application</h2>
816
852
  <div class="sectionbody">
817
- <div class="para"><p>Phusion Passenger supports arbitrary Ruby web applications that follow the
853
+ <div class="paragraph"><p>Phusion Passenger supports arbitrary Ruby web applications that follow the
818
854
  <a href="http://rack.rubyforge.org/">Rack</a> interface.</p></div>
819
- <div class="para"><p>Phusion Passenger assumes that Rack application directories have a certain layout.
855
+ <div class="paragraph"><p>Phusion Passenger assumes that Rack application directories have a certain layout.
820
856
  Suppose that you have a Rack application in <em>/webapps/rackapp</em>. Then that
821
- folder must contain at least two entries:</p></div>
822
- <div class="ilist"><ul>
857
+ folder must contain at least three entries:</p></div>
858
+ <div class="ulist"><ul>
823
859
  <li>
824
860
  <p>
825
861
  <em>config.ru</em>, a Rackup file for starting the Rack application. This file must contain
@@ -838,7 +874,7 @@ folder must contain at least two entries:</p></div>
838
874
  </p>
839
875
  </li>
840
876
  </ul></div>
841
- <div class="para"><p>So <em>/webapps/rackapp</em> must, at minimum, look like this:</p></div>
877
+ <div class="paragraph"><p>So <em>/webapps/rackapp</em> must, at minimum, look like this:</p></div>
842
878
  <div class="listingblock">
843
879
  <div class="content">
844
880
  <pre><tt>/webapps/rackapp
@@ -849,8 +885,8 @@ folder must contain at least two entries:</p></div>
849
885
  |
850
886
  +-- tmp/</tt></pre>
851
887
  </div></div>
852
- <div class="para"><p>Suppose you own the domain <em>www.rackapp.com</em>. You can either deploy your application
853
- to the virtual host's root (i.e. the application will be accessible from the root URL,
888
+ <div class="paragraph"><p>Suppose you own the domain <em>www.rackapp.com</em>. You can either deploy your application
889
+ to the virtual host&#8217;s root (i.e. the application will be accessible from the root URL,
854
890
  <em>http://www.rackapp.com/</em>), or in a sub URI (i.e. the application will be
855
891
  accessible from a sub URL, such as <em>http://www.rackapp.com/rackapp</em>).</p></div>
856
892
  <div class="admonitionblock">
@@ -864,14 +900,14 @@ are run, is &#8220;production&#8221;. You can change this by changing the
864
900
  </tr></table>
865
901
  </div>
866
902
  <h3 id="_tutorial_example_writing_and_deploying_a_hello_world_rack_application">4.1. Tutorial/example: writing and deploying a Hello World Rack application</h3><div style="clear:left"></div>
867
- <div class="para"><p>First we create a Phusion Passenger-compliant Rack directory structure:</p></div>
903
+ <div class="paragraph"><p>First we create a Phusion Passenger-compliant Rack directory structure:</p></div>
868
904
  <div class="listingblock">
869
905
  <div class="content">
870
906
  <pre><tt>$ mkdir /webapps/rack_example
871
907
  $ mkdir /webapps/rack_example/public
872
908
  $ mkdir /webapps/rack_example/tmp</tt></pre>
873
909
  </div></div>
874
- <div class="para"><p>Next, we write a minimal "hello world" Rack application:</p></div>
910
+ <div class="paragraph"><p>Next, we write a minimal "hello world" Rack application:</p></div>
875
911
  <div class="listingblock">
876
912
  <div class="content">
877
913
  <pre><tt>$ cd /webapps/rack_example
@@ -883,7 +919,7 @@ app = proc do |env|
883
919
  end
884
920
  run app</tt></pre>
885
921
  </div></div>
886
- <div class="para"><p>Finally, we deploy it by adding the following configuration options to
922
+ <div class="paragraph"><p>Finally, we deploy it by adding the following configuration options to
887
923
  the Apache configuration file:</p></div>
888
924
  <div class="listingblock">
889
925
  <div class="content">
@@ -892,11 +928,11 @@ the Apache configuration file:</p></div>
892
928
  DocumentRoot /webapps/rack_example/public
893
929
  &lt;/VirtualHost&gt;</tt></pre>
894
930
  </div></div>
895
- <div class="para"><p>And we're done! After an Apache restart, the above Rack application will be available
931
+ <div class="paragraph"><p>And we&#8217;re done! After an Apache restart, the above Rack application will be available
896
932
  under the URL <em>http://www.rackexample.com/</em>.</p></div>
897
- <h3 id="_deploying_to_a_virtual_host_s_root_2">4.2. Deploying to a virtual host's root</h3><div style="clear:left"></div>
898
- <div class="para"><p>Add a virtual host entry to your Apache configuration file. The virtual host's
899
- document root must point to your Rack application's <em>public</em> folder.
933
+ <h3 id="_deploying_to_a_virtual_host_8217_s_root_2">4.2. Deploying to a virtual host&#8217;s root</h3><div style="clear:left"></div>
934
+ <div class="paragraph"><p>Add a virtual host entry to your Apache configuration file. The virtual host&#8217;s
935
+ document root must point to your Rack application&#8217;s <em>public</em> folder.
900
936
  For example:</p></div>
901
937
  <div class="listingblock">
902
938
  <div class="content">
@@ -905,9 +941,9 @@ For example:</p></div>
905
941
  DocumentRoot /webapps/rackapp/public
906
942
  &lt;/VirtualHost&gt;</tt></pre>
907
943
  </div></div>
908
- <div class="para"><p>Then restart Apache. The application has now been deployed.</p></div>
944
+ <div class="paragraph"><p>Then restart Apache. The application has now been deployed.</p></div>
909
945
  <h3 id="deploying_rack_to_sub_uri">4.3. Deploying to a sub URI</h3><div style="clear:left"></div>
910
- <div class="para"><p>Suppose that you already have a virtual host:</p></div>
946
+ <div class="paragraph"><p>Suppose that you already have a virtual host:</p></div>
911
947
  <div class="listingblock">
912
948
  <div class="content">
913
949
  <pre><tt>&lt;VirtualHost *:80&gt;
@@ -915,15 +951,15 @@ For example:</p></div>
915
951
  DocumentRoot /websites/phusion
916
952
  &lt;/VirtualHost&gt;</tt></pre>
917
953
  </div></div>
918
- <div class="para"><p>And you want your Rack application to be accessible from the URL
954
+ <div class="paragraph"><p>And you want your Rack application to be accessible from the URL
919
955
  <em>http://www.phusion.nl/rack</em>.</p></div>
920
- <div class="para"><p>To do this, make a symlink from your Rack application's <em>public</em>
956
+ <div class="paragraph"><p>To do this, make a symlink from your Rack application&#8217;s <em>public</em>
921
957
  folder to a directory in the document root. For example:</p></div>
922
958
  <div class="listingblock">
923
959
  <div class="content">
924
960
  <pre><tt>ln -s /webapps/rackapp/public /websites/phusion/rack</tt></pre>
925
961
  </div></div>
926
- <div class="para"><p>Next, add a <a href="#RackBaseURI">RackBaseURI</a> option to the virtual host configuration:</p></div>
962
+ <div class="paragraph"><p>Next, add a <a href="#RackBaseURI">RackBaseURI</a> option to the virtual host configuration:</p></div>
927
963
  <div class="listingblock">
928
964
  <div class="content">
929
965
  <pre><tt>&lt;VirtualHost *:80&gt;
@@ -932,14 +968,14 @@ folder to a directory in the document root. For example:</p></div>
932
968
  RackBaseURI /rack # This line has been added.
933
969
  &lt;/VirtualHost&gt;</tt></pre>
934
970
  </div></div>
935
- <div class="para"><p>Then restart Apache. The application has now been deployed.</p></div>
971
+ <div class="paragraph"><p>Then restart Apache. The application has now been deployed.</p></div>
936
972
  <div class="admonitionblock">
937
973
  <table><tr>
938
974
  <td class="icon">
939
975
  <img src="./images/icons/tip.png" alt="Tip" />
940
976
  </td>
941
977
  <td class="content">
942
- <div class="para"><p>You can deploy multiple Rack applications under a virtual host, by specifying
978
+ <div class="paragraph"><p>You can deploy multiple Rack applications under a virtual host, by specifying
943
979
  <a href="#RackBaseURI">RackBaseURI</a> multiple times. For example:</p></div>
944
980
  <div class="listingblock">
945
981
  <div class="content">
@@ -954,10 +990,10 @@ folder to a directory in the document root. For example:</p></div>
954
990
  </tr></table>
955
991
  </div>
956
992
  <h3 id="_redeploying_restarting_the_rack_application">4.4. Redeploying (restarting the Rack application)</h3><div style="clear:left"></div>
957
- <div class="para"><p>Deploying a new version of a Rack application is as simple as
993
+ <div class="paragraph"><p>Deploying a new version of a Rack application is as simple as
958
994
  re-uploading the application files, and restarting the application.</p></div>
959
- <div class="para"><p>There are two ways to restart the application:</p></div>
960
- <div class="olist"><ol>
995
+ <div class="paragraph"><p>There are two ways to restart the application:</p></div>
996
+ <div class="olist arabic"><ol class="arabic">
961
997
  <li>
962
998
  <p>
963
999
  By restarting Apache.
@@ -966,19 +1002,19 @@ By restarting Apache.
966
1002
  <li>
967
1003
  <p>
968
1004
  By creating or modifying the file <em>tmp/restart.txt</em> in the Rack
969
- application's root folder. Phusion Passenger will automatically restart the
970
- application.
1005
+ application&#8217;s <a href="#application_root">root folder</a>. Phusion Passenger will
1006
+ automatically restart the application.
971
1007
  </p>
972
1008
  </li>
973
1009
  </ol></div>
974
- <div class="para"><p>For example, to restart our example application, we type this in the
1010
+ <div class="paragraph"><p>For example, to restart our example application, we type this in the
975
1011
  command line:</p></div>
976
1012
  <div class="listingblock">
977
1013
  <div class="content">
978
1014
  <pre><tt>touch /webapps/rackapp/tmp/restart.txt</tt></pre>
979
1015
  </div></div>
980
1016
  <h3 id="_rackup_specifications_for_various_web_frameworks">4.5. Rackup specifications for various web frameworks</h3><div style="clear:left"></div>
981
- <div class="para"><p>This subsection shows example <em>config.ru</em> files for various web frameworks.</p></div>
1017
+ <div class="paragraph"><p>This subsection shows example <em>config.ru</em> files for various web frameworks.</p></div>
982
1018
  <h4 id="_camping">4.5.1. Camping</h4>
983
1019
  <div class="listingblock">
984
1020
  <div class="content">
@@ -994,7 +1030,7 @@ Camping.goes :Blog
994
1030
 
995
1031
  run Rack::Adapter::Camping.new(Blog)</tt></pre>
996
1032
  </div></div>
997
- <div class="para"><p>For Camping versions 2.0 and up, using <tt>run Blog</tt> as the final line will do.</p></div>
1033
+ <div class="paragraph"><p>For Camping versions 2.0 and up, using <tt>run Blog</tt> as the final line will do.</p></div>
998
1034
  <h4 id="_halcyon">4.5.2. Halcyon</h4>
999
1035
  <div class="listingblock">
1000
1036
  <div class="content">
@@ -1019,8 +1055,10 @@ run Mack::Utils::Server.build_app</tt></pre>
1019
1055
  <pre><tt>require 'rubygems'
1020
1056
  require 'merb-core'
1021
1057
 
1022
- Merb::Config.setup(:merb_root =&gt; ".",
1023
- :environment =&gt; ENV['RACK_ENV'])
1058
+ Merb::Config.setup(
1059
+ :merb_root =&gt; File.expand_path(File.dirname(__FILE__)),
1060
+ :environment =&gt; ENV['RACK_ENV']
1061
+ )
1024
1062
  Merb.environment = Merb::Config[:environment]
1025
1063
  Merb.root = Merb::Config[:merb_root]
1026
1064
  Merb::BootLoader.run
@@ -1043,33 +1081,31 @@ require 'sinatra'
1043
1081
 
1044
1082
  root_dir = File.dirname(__FILE__)
1045
1083
 
1046
- Sinatra::Application.default_options.merge!(
1047
- :views =&gt; File.join(root_dir, 'views'),
1048
- :app_file =&gt; File.join(root_dir, 'app.rb'),
1049
- :run =&gt; false,
1050
- :env =&gt; ENV['RACK_ENV'].to_sym
1051
- )
1084
+ set :environment, ENV['RACK_ENV'].to_sym
1085
+ set :root, root_dir
1086
+ set :app_file, File.join(root_dir, 'app.rb')
1087
+ disable :run
1052
1088
 
1053
- run Sinatra.application</tt></pre>
1089
+ run Sinatra::Application</tt></pre>
1054
1090
  </div></div>
1055
1091
  </div>
1056
1092
  <h2 id="_configuring_phusion_passenger">5. Configuring Phusion Passenger</h2>
1057
1093
  <div class="sectionbody">
1058
- <div class="para"><p>After installation, Phusion Passenger does not need any further configurations.
1094
+ <div class="paragraph"><p>After installation, Phusion Passenger does not need any further configurations.
1059
1095
  Nevertheless, the system administrator may be interested in changing
1060
- Phusion Passenger's behavior. Phusion Passenger's Apache module supports the
1096
+ Phusion Passenger&#8217;s behavior. Phusion Passenger&#8217;s Apache module supports the
1061
1097
  following configuration options:</p></div>
1062
1098
  <h3 id="_passengerroot_lt_directory_gt">5.1. PassengerRoot &lt;directory&gt;</h3><div style="clear:left"></div>
1063
- <div class="para"><p>The location to the Phusion Passenger root directory. This configuration option
1099
+ <div class="paragraph"><p>The location to the Phusion Passenger root directory. This configuration option
1064
1100
  is essential to Phusion Passenger. The correct value is given by the installer,
1065
1101
  and should usually not be changed manually.</p></div>
1066
- <div class="para"><p>This required option may only occur once, in the global server configuration.</p></div>
1102
+ <div class="paragraph"><p>This required option may only occur once, in the global server configuration.</p></div>
1067
1103
  <h3 id="_passengerloglevel_lt_integer_gt">5.2. PassengerLogLevel &lt;integer&gt;</h3><div style="clear:left"></div>
1068
- <div class="para"><p>This option allows one to specify how much information Phusion Passenger should
1104
+ <div class="paragraph"><p>This option allows one to specify how much information Phusion Passenger should
1069
1105
  write to the Apache error log file. A higher log level value means that more
1070
1106
  information will be logged.</p></div>
1071
- <div class="para"><p>Possible values are:</p></div>
1072
- <div class="ilist"><ul>
1107
+ <div class="paragraph"><p>Possible values are:</p></div>
1108
+ <div class="ulist"><ul>
1073
1109
  <li>
1074
1110
  <p>
1075
1111
  <em>0</em>: Show only errors and warnings.
@@ -1093,37 +1129,88 @@ information will be logged.</p></div>
1093
1129
  </p>
1094
1130
  </li>
1095
1131
  </ul></div>
1096
- <div class="para"><p>This option may only occur once, in the global server configuration.
1132
+ <div class="paragraph"><p>This option may only occur once, in the global server configuration.
1097
1133
  The default is <em>0</em>.</p></div>
1098
1134
  <h3 id="PassengerRuby">5.3. PassengerRuby &lt;filename&gt;</h3><div style="clear:left"></div>
1099
- <div class="para"><p>This option allows one to specify the Ruby interpreter to use.</p></div>
1100
- <div class="para"><p>This option may only occur once, in the global server configuration.
1135
+ <div class="paragraph"><p>This option allows one to specify the Ruby interpreter to use.</p></div>
1136
+ <div class="paragraph"><p>This option may only occur once, in the global server configuration.
1101
1137
  The default is <em>ruby</em>.</p></div>
1102
- <h3 id="PassengerUseGlobalQueue">5.4. PassengerUseGlobalQueue &lt;on|off&gt;</h3><div style="clear:left"></div>
1103
- <div class="para"><p>Turns the use of global queuing on or off.</p></div>
1104
- <div class="para"><p>This option may only occur once, in the global server configuration. The
1105
- default is <em>off</em>.</p></div>
1106
- <div class="para"><p><em>This feature is sponsored by <a href="http://www.37signals.com/">37signals</a>.</em></p></div>
1107
- <div class="para"><div class="title">What does this option do?</div><p>Recall that Phusion Passenger spawns multiple backend processes (e.g. multiple
1138
+ <h3 id="PassengerAppRoot">5.4. PassengerAppRoot &lt;path/to/root&gt;</h3><div style="clear:left"></div>
1139
+ <div class="paragraph"><p>By default, Phusion Passenger assumes that the application&#8217;s root directory
1140
+ is the parent directory of the <em>public</em> directory. This option allows one to
1141
+ specify the application&#8217;s root independently from the DocumentRoot, which
1142
+ is useful if the <em>public</em> directory lives in a non-standard place.</p></div>
1143
+ <div class="paragraph"><p>This option may occur in the following places:</p></div>
1144
+ <div class="ulist"><ul>
1145
+ <li>
1146
+ <p>
1147
+ In the global server configuration.
1148
+ </p>
1149
+ </li>
1150
+ <li>
1151
+ <p>
1152
+ In a virtual host configuration block.
1153
+ </p>
1154
+ </li>
1155
+ <li>
1156
+ <p>
1157
+ In a <tt>&lt;Directory&gt;</tt> or <tt>&lt;Location&gt;</tt> block.
1158
+ </p>
1159
+ </li>
1160
+ <li>
1161
+ <p>
1162
+ In <em>.htaccess</em>, if <tt>AllowOverride Options</tt> is on.
1163
+ </p>
1164
+ </li>
1165
+ </ul></div>
1166
+ <div class="paragraph"><p>In each place, it may be specified at most once.</p></div>
1167
+ <div class="paragraph"><p>Example:</p></div>
1168
+ <div class="listingblock">
1169
+ <div class="content">
1170
+ <pre><tt>&lt;VirtualHost test.host&gt;
1171
+ DocumentRoot /var/rails/zena/sites/example.com/public
1172
+ PassengerAppRoot /var/rails/zena # &lt;-- normally Phusion Passenger would
1173
+ # have assumed that the application
1174
+ # root is "/var/rails/zena/sites/example.com"
1175
+ &lt;/VirtualHost&gt;</tt></pre>
1176
+ </div></div>
1177
+ <h3 id="PassengerUseGlobalQueue">5.5. PassengerUseGlobalQueue &lt;on|off&gt;</h3><div style="clear:left"></div>
1178
+ <div class="paragraph"><p>Turns the use of global queuing on or off.</p></div>
1179
+ <div class="paragraph"><p>This option may occur in the following places:</p></div>
1180
+ <div class="ulist"><ul>
1181
+ <li>
1182
+ <p>
1183
+ In the global server configuration.
1184
+ </p>
1185
+ </li>
1186
+ <li>
1187
+ <p>
1188
+ In a virtual host configuration block.
1189
+ </p>
1190
+ </li>
1191
+ </ul></div>
1192
+ <div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>off</em>.</p></div>
1193
+ <div class="paragraph"><p><em>This feature is sponsored by <a href="http://www.37signals.com/">37signals</a>.</em></p></div>
1194
+ <div class="paragraph"><div class="title">What does this option do?</div><p>Recall that Phusion Passenger spawns multiple backend processes (e.g. multiple
1108
1195
  Ruby on Rails processes), each which processes HTTP requests serially. One of
1109
- Phusion Passenger's jobs is to forward HTTP requests to a suitable backend
1196
+ Phusion Passenger&#8217;s jobs is to forward HTTP requests to a suitable backend
1110
1197
  process. A backend process may take an arbitrary amount of time to process a
1111
1198
  specific HTTP request. If the websites are (temporarily) under high load, and
1112
1199
  the backend processes cannot process the requests fast enough, then some
1113
1200
  requests may have to be queued.</p></div>
1114
- <div class="para"><p>If global queuing is turned off, then Phusion Passenger will use <em>fair load
1201
+ <div class="paragraph"><p>If global queuing is turned off, then Phusion Passenger will use <em>fair load
1115
1202
  balancing</em>. This means that each backend process will have its own private
1116
1203
  queue. Phusion Passenger will forward an HTTP request to the backend process
1117
1204
  that has the least amount of requests in its queue.</p></div>
1118
- <div class="para"><p>If global queuing is turned on, then Phusion Passenger will use a global queue
1119
- that's shared between all backend processes. If an HTTP request comes in, and
1205
+ <div class="paragraph"><p>If global queuing is turned on, then Phusion Passenger will use a global queue
1206
+ that&#8217;s shared between all backend processes. If an HTTP request comes in, and
1120
1207
  all the backend processes are still busy, then Phusion Passenger will wait until
1121
1208
  at least one backend process is done, and will then forward the request to that
1122
1209
  process.</p></div>
1123
- <div class="para"><div class="title">When to turn on global queuing?</div><p>You should turn on global queuing if one of your web applications may have
1210
+ <div class="paragraph"><div class="title">When to turn on global queuing?</div><p>You should turn on global queuing if one of your web applications may have
1124
1211
  long-running requests.</p></div>
1125
- <div class="para"><p>For example suppose that:</p></div>
1126
- <div class="ilist"><ul>
1212
+ <div class="paragraph"><p>For example suppose that:</p></div>
1213
+ <div class="ulist"><ul>
1127
1214
  <li>
1128
1215
  <p>
1129
1216
  global queuing is turned off.
@@ -1131,13 +1218,13 @@ global queuing is turned off.
1131
1218
  </li>
1132
1219
  <li>
1133
1220
  <p>
1134
- we're currently in a state where all backend processes have 3 requests in
1221
+ we&#8217;re currently in a state where all backend processes have 3 requests in
1135
1222
  their queue, except for a single backend process, which has 1 request in its
1136
1223
  queue.
1137
1224
  </p>
1138
1225
  </li>
1139
1226
  </ul></div>
1140
- <div class="para"><p>The situation looks like this:</p></div>
1227
+ <div class="paragraph"><p>The situation looks like this:</p></div>
1141
1228
  <div class="listingblock">
1142
1229
  <div class="content">
1143
1230
  <pre><tt>Backend process A: [* ] (1 request in queue)
@@ -1145,9 +1232,9 @@ Backend process B: [*** ] (3 requests in queue)
1145
1232
  Backend process C: [*** ] (3 requests in queue)
1146
1233
  Backend process D: [*** ] (3 requests in queue)</tt></pre>
1147
1234
  </div></div>
1148
- <div class="para"><p>Each process is currently serving short-running requests.</p></div>
1149
- <div class="para"><p>Phusion Passenger will forward the next request to backend process A. A will
1150
- now have 2 items in its queue. We'll mark this new request with an X:</p></div>
1235
+ <div class="paragraph"><p>Each process is currently serving short-running requests.</p></div>
1236
+ <div class="paragraph"><p>Phusion Passenger will forward the next request to backend process A. A will
1237
+ now have 2 items in its queue. We&#8217;ll mark this new request with an X:</p></div>
1151
1238
  <div class="listingblock">
1152
1239
  <div class="content">
1153
1240
  <pre><tt>Backend process A: [*X ] (2 request in queue)
@@ -1155,8 +1242,8 @@ Backend process B: [*** ] (3 requests in queue)
1155
1242
  Backend process C: [*** ] (3 requests in queue)
1156
1243
  Backend process D: [*** ] (3 requests in queue)</tt></pre>
1157
1244
  </div></div>
1158
- <div class="para"><p>Assuming that B, C and D still aren't done with their current request, the next
1159
- HTTP request - let's call this Y - will be forwarded to backend process A as
1245
+ <div class="paragraph"><p>Assuming that B, C and D still aren&#8217;t done with their current request, the next
1246
+ HTTP request - let&#8217;s call this Y - will be forwarded to backend process A as
1160
1247
  well, because it has the least number of items in its queue:</p></div>
1161
1248
  <div class="listingblock">
1162
1249
  <div class="content">
@@ -1165,43 +1252,254 @@ Backend process B: [*** ] (3 requests in queue)
1165
1252
  Backend process C: [*** ] (3 requests in queue)
1166
1253
  Backend process D: [*** ] (3 requests in queue)</tt></pre>
1167
1254
  </div></div>
1168
- <div class="para"><p>But if request X happens to be a long-running request that needs 60 seconds to
1169
- complete, then we'll have a problem. Y won't be processed for at least 60
1255
+ <div class="paragraph"><p>But if request X happens to be a long-running request that needs 60 seconds to
1256
+ complete, then we&#8217;ll have a problem. Y won&#8217;t be processed for at least 60
1170
1257
  seconds. It would have been a better idea if Y was forward to processes B, C or
1171
1258
  D instead, because they only have short-living requests in their queues.</p></div>
1172
- <div class="para"><p>This problem will be avoided entirely if you turn global queuing on. With global
1259
+ <div class="paragraph"><p>This problem will be avoided entirely if you turn global queuing on. With global
1173
1260
  queuing, all backend processes will share the same queue. The first backend
1174
1261
  process that becomes available will take from the queue, and so this
1175
1262
  &#8220;queuing-behind-long-running-request&#8221; problem will never occur.</p></div>
1176
- <div class="para"><p>Turning global queuing off will yield a minor performance improvement (about 5%,
1177
- depending on how fast/slow your web application is), which is why it's off by
1263
+ <div class="paragraph"><p>Turning global queuing off will yield a minor performance improvement (about 5%,
1264
+ depending on how fast/slow your web application is), which is why it&#8217;s off by
1178
1265
  default.</p></div>
1179
- <h3 id="PassengerUserSwitching">5.5. PassengerUserSwitching &lt;on|off&gt;</h3><div style="clear:left"></div>
1180
- <div class="para"><p>Whether to enable <a href="#user_switching">user switching support</a>.</p></div>
1181
- <div class="para"><p>This option may only occur once, in the global server configuration.
1266
+ <h3 id="PassengerUserSwitching">5.6. PassengerUserSwitching &lt;on|off&gt;</h3><div style="clear:left"></div>
1267
+ <div class="paragraph"><p>Whether to enable <a href="#user_switching">user switching support</a>.</p></div>
1268
+ <div class="paragraph"><p>This option may only occur once, in the global server configuration.
1182
1269
  The default value is <em>on</em>.</p></div>
1183
- <h3 id="PassengerDefaultUser">5.6. PassengerDefaultUser &lt;username&gt;</h3><div style="clear:left"></div>
1184
- <div class="para"><p>Passenger enables <a href="#user_switching">user switching support</a> by default.
1270
+ <h3 id="PassengerDefaultUser">5.7. PassengerDefaultUser &lt;username&gt;</h3><div style="clear:left"></div>
1271
+ <div class="paragraph"><p>Passenger enables <a href="#user_switching">user switching support</a> by default.
1185
1272
  This configuration option allows one to specify which user Rails/Rack
1186
1273
  applications must run as, if user switching fails or is disabled.</p></div>
1187
- <div class="para"><p>This option may only occur once, in the global server configuration.
1274
+ <div class="paragraph"><p>This option may only occur once, in the global server configuration.
1188
1275
  The default value is <em>nobody</em>.</p></div>
1189
- <h3 id="_resource_control_and_optimization_options">5.7. Resource control and optimization options</h3><div style="clear:left"></div>
1190
- <h4 id="_passengermaxpoolsize_lt_integer_gt">5.7.1. PassengerMaxPoolSize &lt;integer&gt;</h4>
1191
- <div class="para"><p>The maximum number of Ruby on Rails or Rack application instances that may
1276
+ <h3 id="PassengerHighPerformance">5.8. PassengerHighPerformance &lt;on|off&gt;</h3><div style="clear:left"></div>
1277
+ <div class="paragraph"><p>By default, Phusion Passenger is compatible with mod_rewrite and most other
1278
+ Apache modules. However, a lot of effort is required in order to be compatible.
1279
+ If you turn <em>PassengerHighPerformance</em> to <em>on</em>, then Phusion Passenger will be
1280
+ a little faster, in return for reduced compatibility with other Apache modules.</p></div>
1281
+ <div class="paragraph"><p>In places where <em>PassengerHighPerformance</em> is turned on, mod_rewrite rules will
1282
+ likely not work. mod_autoindex (the module which displays a directory index)
1283
+ will also not work. Other Apache modules may or may not work, depending on what
1284
+ they exactly do. We recommend you to find out how other modules behave in high
1285
+ performance mode via testing.</p></div>
1286
+ <div class="paragraph"><p>This option is <strong>not</strong> an all-or-nothing global option: you can enable high
1287
+ performance mode for certain virtual hosts or certain URLs only.
1288
+ The <em>PassengerHighPerformance</em> option may occur in the following places:</p></div>
1289
+ <div class="ulist"><ul>
1290
+ <li>
1291
+ <p>
1292
+ In the global server configuration.
1293
+ </p>
1294
+ </li>
1295
+ <li>
1296
+ <p>
1297
+ In a virtual host configuration block.
1298
+ </p>
1299
+ </li>
1300
+ <li>
1301
+ <p>
1302
+ In a <tt>&lt;Directory&gt;</tt> or <tt>&lt;Location&gt;</tt> block.
1303
+ </p>
1304
+ </li>
1305
+ <li>
1306
+ <p>
1307
+ In <em>.htaccess</em>.
1308
+ </p>
1309
+ </li>
1310
+ </ul></div>
1311
+ <div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>off</em>,
1312
+ so high performance mode is disabled by default, and you have to explicitly
1313
+ enable it.</p></div>
1314
+ <div class="paragraph"><div class="title">When to enable high performance mode?</div><p>If you do not use mod_rewrite or other Apache modules then it might make
1315
+ sense to enable high performance mode.</p></div>
1316
+ <div class="paragraph"><p>It&#8217;s likely that some of your applications depend on mod_rewrite or other
1317
+ Apache modules, while some do not. In that case you can enable high performance
1318
+ for only those applications that don&#8217;t use other Apache modules. For example:</p></div>
1319
+ <div class="listingblock">
1320
+ <div class="content">
1321
+ <pre><tt>&lt;VirtualHost *:80&gt;
1322
+ ServerName www.foo.com
1323
+ DocumentRoot /apps/foo/public
1324
+ .... mod_rewrite rules or options for other Apache modules here ...
1325
+ &lt;/VirtualHost&gt;
1326
+
1327
+ &lt;VirtualHost *:80&gt;
1328
+ ServerName www.bar.com
1329
+ DocumentRoot /apps/bar/public
1330
+ PassengerHighPerformance on
1331
+ &lt;/VirtualHost&gt;</tt></pre>
1332
+ </div></div>
1333
+ <div class="paragraph"><p>In the above example, high performance mode is only enabled for www.bar.com.
1334
+ It is disabled for everything else.</p></div>
1335
+ <div class="paragraph"><p>If your application generally depends on mod_rewrite or other Apache modules,
1336
+ but a certain URL that&#8217;s accessed often doesn&#8217;t depend on those other modules,
1337
+ then you can enable high performance mode for a certain URL only. For example:</p></div>
1338
+ <div class="listingblock">
1339
+ <div class="content">
1340
+ <pre><tt>&lt;VirtualHost *:80&gt;
1341
+ ServerName www.foo.com
1342
+ DocumentRoot /apps/foo/public
1343
+ .... mod_rewrite rules or options for other Apache modules here ...
1344
+
1345
+ &lt;Location /chatroom/ajax_update_poll&gt;
1346
+ PassengerHighPerformance on
1347
+ &lt;/Location&gt;
1348
+ &lt;/VirtualHost&gt;</tt></pre>
1349
+ </div></div>
1350
+ <div class="paragraph"><p>This enables high performance mode for
1351
+ <a href="http://www.foo.com/chatroom/ajax_update_poll">http://www.foo.com/chatroom/ajax_update_poll</a> only.</p></div>
1352
+ <h3 id="_passengerenabled_lt_on_off_gt">5.9. PassengerEnabled &lt;on|off&gt;</h3><div style="clear:left"></div>
1353
+ <div class="paragraph"><p>You can set this option to <em>off</em> to completely disable Phusion Passenger for
1354
+ a certain location. This is useful if, for example, you want to integrate a PHP
1355
+ application into the same virtual host as a Rails application.</p></div>
1356
+ <div class="paragraph"><p>Suppose that you have a Rails application in <em>/apps/foo</em>. Suppose that you&#8217;ve
1357
+ dropped Wordpress&#8201;&#8212;&#8201;a blogging application written in PHP&#8201;&#8212;&#8201;in
1358
+ <em>/apps/foo/public/wordpress</em>. You can then configure Phusion Passenger as
1359
+ follows:</p></div>
1360
+ <div class="listingblock">
1361
+ <div class="content">
1362
+ <pre><tt>&lt;VirtualHost *:80&gt;
1363
+ ServerName www.foo.com
1364
+ DocumentRoot /apps/foo/public
1365
+ &lt;Location /wordpress&gt;
1366
+ PassengerEnabled off
1367
+ AllowOverride all # &lt;-- Makes Wordpress's .htaccess file work.
1368
+ &lt;/Location&gt;
1369
+ &lt;/VirtualHost&gt;</tt></pre>
1370
+ </div></div>
1371
+ <div class="paragraph"><p>This way, Phusion Passenger will not interfere with Wordpress.</p></div>
1372
+ <div class="paragraph"><p><em>PassengerEnabled</em> may occur in the following places:</p></div>
1373
+ <div class="ulist"><ul>
1374
+ <li>
1375
+ <p>
1376
+ In the global server configuration.
1377
+ </p>
1378
+ </li>
1379
+ <li>
1380
+ <p>
1381
+ In a virtual host configuration block.
1382
+ </p>
1383
+ </li>
1384
+ <li>
1385
+ <p>
1386
+ In a <tt>&lt;Directory&gt;</tt> or <tt>&lt;Location&gt;</tt> block.
1387
+ </p>
1388
+ </li>
1389
+ <li>
1390
+ <p>
1391
+ In <em>.htaccess</em>.
1392
+ </p>
1393
+ </li>
1394
+ </ul></div>
1395
+ <div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>on</em>.</p></div>
1396
+ <h3 id="_passengertempdir_lt_directory_gt">5.10. PassengerTempDir &lt;directory&gt;</h3><div style="clear:left"></div>
1397
+ <div class="paragraph"><p>Specifies the directory that Phusion Passenger should use for storing temporary
1398
+ files. This includes things such as Unix socket files, buffered file uploads,
1399
+ etc.</p></div>
1400
+ <div class="paragraph"><p>This option may be specified once, in the global server configuration. The
1401
+ default temp directory that Phusion Passenger uses is <em>/tmp</em>.</p></div>
1402
+ <div class="paragraph"><p>This option is especially useful if Apache is not allowed to write to /tmp
1403
+ (which is the case on some systems with strict SELinux policies) or if the
1404
+ partition that /tmp lives on doesn&#8217;t have enough disk space.</p></div>
1405
+ <div class="paragraph"><div class="title">Command line tools</div><p>Some Phusion Passenger command line administration tools, such as
1406
+ <tt>passenger-status</tt>, must know what Phusion Passenger&#8217;s temp directory is
1407
+ in order to function properly. You can pass the directory through the
1408
+ <tt>PASSENGER_TMPDIR</tt> environment variable, or the <tt>TMPDIR</tt> environment variable
1409
+ (the former will be used if both are specified).</p></div>
1410
+ <div class="paragraph"><p>For example, if you set <em>PassengerTempDir</em> to <em>/my_temp_dir</em>, then invoke
1411
+ <tt>passenger-status</tt> after you&#8217;ve set the <tt>PASSENGER_TMPDIR</tt> or <tt>TMPDIR</tt>
1412
+ environment variable, like this:</p></div>
1413
+ <div class="listingblock">
1414
+ <div class="content">
1415
+ <pre><tt>export PASSENGER_TMPDIR=/my_temp-dir
1416
+ sudo -E passenger-status
1417
+ # The -E option tells 'sudo' to preserve environment variables.</tt></pre>
1418
+ </div></div>
1419
+ <h3 id="_passengerrestartdir_lt_directory_gt">5.11. PassengerRestartDir &lt;directory&gt;</h3><div style="clear:left"></div>
1420
+ <div class="paragraph"><p>As described in the deployment chapters of this document, Phusion Passenger
1421
+ checks the file <em>tmp/restart.txt</em> in the applications'
1422
+ <a href="#application_root">root directory</a> for restarting applications. Sometimes it
1423
+ may be desirable for Phusion Passenger to look in a different directory instead,
1424
+ for example for security reasons (see below). This option allows you to
1425
+ customize the directory in which <em>restart.txt</em> is searched for.</p></div>
1426
+ <div class="paragraph"><p>You may specify <em>PassengerRestartDir</em> in the following places:</p></div>
1427
+ <div class="ulist"><ul>
1428
+ <li>
1429
+ <p>
1430
+ In the global server configuration.
1431
+ </p>
1432
+ </li>
1433
+ <li>
1434
+ <p>
1435
+ In a virtual host configuration block.
1436
+ </p>
1437
+ </li>
1438
+ <li>
1439
+ <p>
1440
+ In a <tt>&lt;Directory&gt;</tt> or <tt>&lt;Location&gt;</tt> block.
1441
+ </p>
1442
+ </li>
1443
+ <li>
1444
+ <p>
1445
+ In <em>.htaccess</em>, if <tt>AllowOverrides Options</tt> is enabled.
1446
+ </p>
1447
+ </li>
1448
+ </ul></div>
1449
+ <div class="paragraph"><p>In each place, it may be specified at most once.</p></div>
1450
+ <div class="paragraph"><p>You can either set it to an absolute directory, or to a directory relative to
1451
+ the <a href="#application_root">application root</a>. Examples:</p></div>
1452
+ <div class="listingblock">
1453
+ <div class="content">
1454
+ <pre><tt>&lt;VirtualHost *:80&gt;
1455
+ ServerName www.foo.com
1456
+ # Phusion Passenger will check for /apps/foo/public/tmp/restart.txt
1457
+ DocumentRoot /apps/foo/public
1458
+ &lt;/VirtualHost&gt;
1459
+
1460
+ &lt;VirtualHost *:80&gt;
1461
+ ServerName www.bar.com
1462
+ DocumentRoot /apps/bar/public
1463
+ # An absolute filename is given; Phusion Passenger will
1464
+ # check for /restart_files/bar/restart.txt
1465
+ PassengerRestartDir /restart_files/bar
1466
+ &lt;/VirtualHost&gt;
1467
+
1468
+ &lt;VirtualHost *:80&gt;
1469
+ ServerName www.baz.com
1470
+ DocumentRoot /apps/baz/public
1471
+ # A relative filename is given; Phusion Passenger will
1472
+ # check for /apps/baz/restart_files/restart.txt
1473
+ #
1474
+ # Note that this directory is relative to the APPLICATION ROOT, *not*
1475
+ # the value of DocumentRoot!
1476
+ PassengerRestartDir restart_files
1477
+ &lt;/VirtualHost&gt;</tt></pre>
1478
+ </div></div>
1479
+ <div class="paragraph"><div class="title">What are the security reasons for wanting to customize PassengerRestartDir?</div><p>Touching restart.txt will cause Phusion Passenger to restart the application.
1480
+ So anybody who can touch restart.txt can effectively cause a Denial-of-Service
1481
+ attack by touching restart.txt over and over. If your web server or one of your
1482
+ web applications has the permission to touch restart.txt, and one of them has a
1483
+ security flaw which allows an attacker to touch restart.txt, then that will
1484
+ allow the attacker to cause a Denial-of-Service.</p></div>
1485
+ <div class="paragraph"><p>You can prevent this from happening by pointing PassengerRestartDir to a
1486
+ directory that&#8217;s readable by Apache, but only writable by administrators.</p></div>
1487
+ <h3 id="_resource_control_and_optimization_options">5.12. Resource control and optimization options</h3><div style="clear:left"></div>
1488
+ <h4 id="_passengermaxpoolsize_lt_integer_gt">5.12.1. PassengerMaxPoolSize &lt;integer&gt;</h4>
1489
+ <div class="paragraph"><p>The maximum number of Ruby on Rails or Rack application instances that may
1192
1490
  be simultaneously active. A larger number results in higher memory usage,
1193
1491
  but improved ability to handle concurrent HTTP clients.</p></div>
1194
- <div class="para"><p>The optimal value depends on your system's hardware and the server's average
1492
+ <div class="paragraph"><p>The optimal value depends on your system&#8217;s hardware and the server&#8217;s average
1195
1493
  load. You should experiment with different values. But generally speaking,
1196
1494
  the value should be at least equal to the number of CPUs (or CPU cores) that
1197
1495
  you have. If your system has 2 GB of RAM, then we recommend a value of <em>30</em>.
1198
1496
  If your system is a Virtual Private Server (VPS) and has about 256 MB RAM, and
1199
1497
  is also running other services such as MySQL, then we recommend a value of <em>2</em>.</p></div>
1200
- <div class="para"><p>If you find that your server is unable to handle the load on your Rails/Rack websites
1498
+ <div class="paragraph"><p>If you find that your server is unable to handle the load on your Rails/Rack websites
1201
1499
  (i.e. running out of memory) then you should lower this value. (Though if your
1202
1500
  sites are really that popular, then you should strongly consider upgrading your
1203
1501
  hardware or getting more servers.)</p></div>
1204
- <div class="para"><p>This option may only occur once, in the global server configuration.
1502
+ <div class="paragraph"><p>This option may only occur once, in the global server configuration.
1205
1503
  The default value is <em>6</em>.</p></div>
1206
1504
  <div class="admonitionblock">
1207
1505
  <table><tr>
@@ -1209,40 +1507,142 @@ The default value is <em>6</em>.</p></div>
1209
1507
  <img src="./images/icons/tip.png" alt="Tip" />
1210
1508
  </td>
1211
1509
  <td class="content">We strongly recommend you to <a href="#reducing_memory_usage">use Ruby Enterprise Edition</a>. This allows you to reduce the memory usage of your Ruby on Rails applications
1212
- by about 33%. And it's not hard to install.</td>
1510
+ by about 33%. And it&#8217;s not hard to install.</td>
1213
1511
  </tr></table>
1214
1512
  </div>
1215
- <h4 id="_passengermaxinstancesperapp_lt_integer_gt">5.7.2. PassengerMaxInstancesPerApp &lt;integer&gt;</h4>
1216
- <div class="para"><p>The maximum number of application instances that may be simultaneously active
1513
+ <h4 id="_passengermaxinstancesperapp_lt_integer_gt">5.12.2. PassengerMaxInstancesPerApp &lt;integer&gt;</h4>
1514
+ <div class="paragraph"><p>The maximum number of application instances that may be simultaneously active
1217
1515
  for a single application. This helps to make sure that a single application
1218
1516
  will not occupy all available slots in the application pool.</p></div>
1219
- <div class="para"><p>This value must be less than <a href="#PassengerMaxPoolSize">PassengerMaxPoolSize</a>. A value of 0
1517
+ <div class="paragraph"><p>This value must be less than <a href="#PassengerMaxPoolSize">PassengerMaxPoolSize</a>. A value of 0
1220
1518
  means that there is no limit placed on the number of instances a single application
1221
1519
  may use, i.e. only the global limit of <a href="#PassengerMaxPoolSize">PassengerMaxPoolSize</a>
1222
1520
  will be enforced.</p></div>
1223
- <div class="para"><p>This option may only occur once, in the global server configuration.
1521
+ <div class="paragraph"><p>This option may only occur once, in the global server configuration.
1224
1522
  The default value is <em>0</em>.</p></div>
1225
- <h4 id="PassengerPoolIdleTime">5.7.3. PassengerPoolIdleTime &lt;integer&gt;</h4>
1226
- <div class="para"><p>The maximum number of seconds that an application instance may be idle. That is,
1227
- if an application instance hasn't received any traffic after the given number of
1523
+ <h4 id="PassengerPoolIdleTime">5.12.3. PassengerPoolIdleTime &lt;integer&gt;</h4>
1524
+ <div class="paragraph"><p>The maximum number of seconds that an application instance may be idle. That is,
1525
+ if an application instance hasn&#8217;t received any traffic after the given number of
1228
1526
  seconds, then it will be shutdown in order to conserve memory.</p></div>
1229
- <div class="para"><p>Decreasing this value means that applications will have to be spawned
1527
+ <div class="paragraph"><p>Decreasing this value means that applications will have to be spawned
1230
1528
  more often. Since spawning is a relatively slow operation, some visitors may
1231
1529
  notice a small delay when they visit your Rails/Rack website. However, it will also
1232
1530
  free up resources used by applications more quickly.</p></div>
1233
- <div class="para"><p>The optimal value depends on the average time that a visitor spends on a single
1531
+ <div class="paragraph"><p>The optimal value depends on the average time that a visitor spends on a single
1234
1532
  Rails/Rack web page. We recommend a value of <tt>2 * x</tt>, where <tt>x</tt> is the average
1235
1533
  number of seconds that a visitor spends on a single Rails/Rack web page. But your
1236
1534
  mileage may vary.</p></div>
1237
- <div class="para"><p>This option may only occur once, in the global server configuration.
1535
+ <div class="paragraph"><p>When this value is set to <em>0</em>, application instances will not be shutdown unless
1536
+ it&#8217;s really necessary, i.e. when Phusion Passenger is out of worker processes
1537
+ for a given application and one of the inactive application instances needs to
1538
+ make place for another application instance. Setting the value to 0 is
1539
+ recommended if you&#8217;re on a non-shared host that&#8217;s only running a few
1540
+ applications, each which must be available at all times.</p></div>
1541
+ <div class="paragraph"><p>This option may only occur once, in the global server configuration.
1238
1542
  The default value is <em>300</em>.</p></div>
1239
- <h3 id="_ruby_on_rails_specific_options">5.8. Ruby on Rails-specific options</h3><div style="clear:left"></div>
1240
- <h4 id="_railsautodetect_lt_on_off_gt">5.8.1. RailsAutoDetect &lt;on|off&gt;</h4>
1241
- <div class="para"><p>Whether Phusion Passenger should automatically detect whether a virtual host's
1543
+ <h4 id="PassengerMaxRequests">5.12.4. PassengerMaxRequests &lt;integer&gt;</h4>
1544
+ <div class="paragraph"><p>The maximum number of requests an application instance will process. After
1545
+ serving that many requests, the application instance will be shut down and
1546
+ Phusion Passenger will restart it. A value of 0 means that there is no maximum:
1547
+ an application instance will thus be shut down when its idle timeout has been
1548
+ reached.</p></div>
1549
+ <div class="paragraph"><p>This option is useful if your application is leaking memory. By shutting
1550
+ it down after a certain number of requests, all of its memory is guaranteed
1551
+ to be freed by the operating system.</p></div>
1552
+ <div class="paragraph"><p>This option may occur in the following places:</p></div>
1553
+ <div class="ulist"><ul>
1554
+ <li>
1555
+ <p>
1556
+ In the global server configuration.
1557
+ </p>
1558
+ </li>
1559
+ <li>
1560
+ <p>
1561
+ In a virtual host configuration block.
1562
+ </p>
1563
+ </li>
1564
+ <li>
1565
+ <p>
1566
+ In a <tt>&lt;Directory&gt;</tt> or <tt>&lt;Location&gt;</tt> block.
1567
+ </p>
1568
+ </li>
1569
+ <li>
1570
+ <p>
1571
+ In <em>.htaccess</em>, if <tt>AllowOverride Limits</tt> is on.
1572
+ </p>
1573
+ </li>
1574
+ </ul></div>
1575
+ <div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>0</em>.</p></div>
1576
+ <div class="admonitionblock">
1577
+ <table><tr>
1578
+ <td class="icon">
1579
+ <img src="./images/icons/caution.png" alt="Caution" />
1580
+ </td>
1581
+ <td class="content">
1582
+ <div class="paragraph"><p>The <a href="#PassengerMaxRequests">PassengerMaxRequests</a> directive should be considered
1583
+ as a workaround for misbehaving applications. It is advised that you fix the
1584
+ problem in your application rather than relying on these directives as a
1585
+ measure to avoid memory leaks.</p></div>
1586
+ </td>
1587
+ </tr></table>
1588
+ </div>
1589
+ <h4 id="_passengerstatthrottlerate_lt_integer_gt">5.12.5. PassengerStatThrottleRate &lt;integer&gt;</h4>
1590
+ <div class="paragraph"><p>By default, Phusion Passenger performs several filesystem checks (or, in
1591
+ programmers jargon, <em>stat() calls</em>) each time a request is processed:</p></div>
1592
+ <div class="ulist"><ul>
1593
+ <li>
1594
+ <p>
1595
+ It checks whether <em>config/environment.rb</em>, <em>config.ru</em> or <em>passenger_wsgi.py</em>
1596
+ is present, in order to autodetect Rails, Rack and WSGI applications.
1597
+ </p>
1598
+ </li>
1599
+ <li>
1600
+ <p>
1601
+ It checks whether <em>restart.txt</em> has changed or whether <em>always_restart.txt</em>
1602
+ exists, in order to determine whether the application should be restarted.
1603
+ </p>
1604
+ </li>
1605
+ </ul></div>
1606
+ <div class="paragraph"><p>On some systems where disk I/O is expensive, e.g. systems where the harddisk is
1607
+ already being heavily loaded, or systems where applications are stored on NFS
1608
+ shares, these filesystem checks can incur a lot of overhead.</p></div>
1609
+ <div class="paragraph"><p>You can decrease or almost entirely eliminate this overhead by setting
1610
+ <em>PassengerStatThrottleRate</em>. Setting this option to a value of <em>x</em> means that
1611
+ the above list of filesystem checks will be performed at most once every <em>x</em>
1612
+ seconds. Setting it to a value of <em>0</em> means that no throttling will take place,
1613
+ or in other words, that the above list of filesystem checks will be performed on
1614
+ every request.</p></div>
1615
+ <div class="paragraph"><p>This option may occur in the following places:</p></div>
1616
+ <div class="ulist"><ul>
1617
+ <li>
1618
+ <p>
1619
+ In the global server configuration.
1620
+ </p>
1621
+ </li>
1622
+ <li>
1623
+ <p>
1624
+ In a virtual host configuration block.
1625
+ </p>
1626
+ </li>
1627
+ <li>
1628
+ <p>
1629
+ In a <tt>&lt;Directory&gt;</tt> or <tt>&lt;Location&gt;</tt> block.
1630
+ </p>
1631
+ </li>
1632
+ <li>
1633
+ <p>
1634
+ In <em>.htaccess</em>, if <tt>AllowOverride Limits</tt> is on.
1635
+ </p>
1636
+ </li>
1637
+ </ul></div>
1638
+ <div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>0</em>.</p></div>
1639
+ <h3 id="_ruby_on_rails_specific_options">5.13. Ruby on Rails-specific options</h3><div style="clear:left"></div>
1640
+ <h4 id="_railsautodetect_lt_on_off_gt">5.13.1. RailsAutoDetect &lt;on|off&gt;</h4>
1641
+ <div class="paragraph"><p>Whether Phusion Passenger should automatically detect whether a virtual host&#8217;s
1242
1642
  document root is a Ruby on Rails application. The default is <em>on</em>.</p></div>
1243
- <div class="para"><p>This option may occur in the global server configuration or in a virtual host
1643
+ <div class="paragraph"><p>This option may occur in the global server configuration or in a virtual host
1244
1644
  configuration block.</p></div>
1245
- <div class="para"><p>For example, consider the following configuration:</p></div>
1645
+ <div class="paragraph"><p>For example, consider the following configuration:</p></div>
1246
1646
  <div class="listingblock">
1247
1647
  <div class="content">
1248
1648
  <pre><tt>RailsAutoDetect off
@@ -1251,10 +1651,10 @@ configuration block.</p></div>
1251
1651
  DocumentRoot /webapps/mycook/public
1252
1652
  &lt;/VirtualHost&gt;</tt></pre>
1253
1653
  </div></div>
1254
- <div class="para"><p>If one goes to <em>http://www.mycook.com/</em>, the visitor will see the contents of
1654
+ <div class="paragraph"><p>If one goes to <em>http://www.mycook.com/</em>, the visitor will see the contents of
1255
1655
  the <em>/webapps/mycook/public</em> folder, instead of the output of the Ruby on Rails
1256
1656
  application.</p></div>
1257
- <div class="para"><p>It is possible to explicitly specify that the host is a Ruby on Rails
1657
+ <div class="paragraph"><p>It is possible to explicitly specify that the host is a Ruby on Rails
1258
1658
  application by using the <a href="#RailsBaseURI">RailsBaseURI</a> configuration option:</p></div>
1259
1659
  <div class="listingblock">
1260
1660
  <div class="content">
@@ -1265,23 +1665,61 @@ application by using the <a href="#RailsBaseURI">RailsBaseURI</a> configuration
1265
1665
  RailsBaseURI / # This line has been added.
1266
1666
  &lt;/VirtualHost&gt;</tt></pre>
1267
1667
  </div></div>
1268
- <h4 id="RailsBaseURI">5.8.2. RailsBaseURI &lt;uri&gt;</h4>
1269
- <div class="para"><p>Used to specify that the given URI is a Rails application. See
1668
+ <h4 id="RailsBaseURI">5.13.2. RailsBaseURI &lt;uri&gt;</h4>
1669
+ <div class="paragraph"><p>Used to specify that the given URI is a Rails application. See
1270
1670
  <a href="#deploying_rails_to_sub_uri">Deploying Rails to a sub URI</a> for an example.</p></div>
1271
- <div class="para"><p>It is allowed to specify this option multiple times. Do this to deploy multiple
1671
+ <div class="paragraph"><p>It is allowed to specify this option multiple times. Do this to deploy multiple
1272
1672
  Rails applications in different sub-URIs under the same virtual host.</p></div>
1273
- <div class="para"><p>This option may occur in the global server configuration or in a
1274
- virtual host configuration block.</p></div>
1275
- <h4 id="RailsAllowModRewrite">5.8.3. RailsAllowModRewrite &lt;on|off&gt;</h4>
1276
- <div class="para"><p>If enabled, Phusion Passenger will not override mod_rewrite rules. Please read
1277
- <a href="#conflicting_apache_modules">Conflicting Apache modules</a> for details.</p></div>
1278
- <div class="para"><p>This option may occur once, in the global server configuration or in a virtual host
1279
- configuration block. The default value is <em>off</em>.</p></div>
1280
- <h4 id="rails_env">5.8.4. RailsEnv &lt;string&gt;</h4>
1281
- <div class="para"><p>This option allows one to specify the default <tt>RAILS_ENV</tt> value.</p></div>
1282
- <div class="para"><p>This option may occur once, in the global server configuration or in a virtual host
1283
- configuration block. The default value is <em>production</em>.</p></div>
1284
- <h4 id="RailsSpawnMethod">5.8.5. RailsSpawnMethod &lt;string&gt;</h4>
1673
+ <div class="paragraph"><p>This option may occur in the following places:</p></div>
1674
+ <div class="ulist"><ul>
1675
+ <li>
1676
+ <p>
1677
+ In the global server configuration.
1678
+ </p>
1679
+ </li>
1680
+ <li>
1681
+ <p>
1682
+ In a virtual host configuration block.
1683
+ </p>
1684
+ </li>
1685
+ <li>
1686
+ <p>
1687
+ In a <tt>&lt;Directory&gt;</tt> or <tt>&lt;Location&gt;</tt> block.
1688
+ </p>
1689
+ </li>
1690
+ <li>
1691
+ <p>
1692
+ In <em>.htaccess</em>, if <tt>AllowOverride Options</tt> is on.
1693
+ </p>
1694
+ </li>
1695
+ </ul></div>
1696
+ <h4 id="rails_env">5.13.3. RailsEnv &lt;string&gt;</h4>
1697
+ <div class="paragraph"><p>This option allows one to specify the default <tt>RAILS_ENV</tt> value.</p></div>
1698
+ <div class="paragraph"><p>This option may occur in the following places:</p></div>
1699
+ <div class="ulist"><ul>
1700
+ <li>
1701
+ <p>
1702
+ In the global server configuration.
1703
+ </p>
1704
+ </li>
1705
+ <li>
1706
+ <p>
1707
+ In a virtual host configuration block.
1708
+ </p>
1709
+ </li>
1710
+ <li>
1711
+ <p>
1712
+ In a <tt>&lt;Directory&gt;</tt> or <tt>&lt;Location&gt;</tt> block.
1713
+ </p>
1714
+ </li>
1715
+ <li>
1716
+ <p>
1717
+ In <em>.htaccess</em>, if <tt>AllowOverride Options</tt> is on.
1718
+ </p>
1719
+ </li>
1720
+ </ul></div>
1721
+ <div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>production</em>.</p></div>
1722
+ <h4 id="RailsSpawnMethod">5.13.4. RailsSpawnMethod &lt;string&gt;</h4>
1285
1723
  <div class="admonitionblock">
1286
1724
  <table><tr>
1287
1725
  <td class="icon">
@@ -1289,64 +1727,128 @@ configuration block. The default value is <em>production</em>.</p></div>
1289
1727
  </td>
1290
1728
  <td class="content">
1291
1729
  <div class="title">"What spawn method should I use?"</div>
1292
- <div class="para"><p>This subsection attempts to describe spawn methods, but it's okay if you don't (want to)
1293
- understand it, as it's mostly a technical detail. You can basically follow this rule of thumb:</p></div>
1730
+ <div class="paragraph"><p>This subsection attempts to describe spawn methods, but it&#8217;s okay if you don&#8217;t (want to)
1731
+ understand it, as it&#8217;s mostly a technical detail. You can basically follow this rule of thumb:</p></div>
1294
1732
  <div class="sidebarblock">
1295
1733
  <div class="sidebar-content">
1296
- <div class="para"><p>If your application works on Mongrel, but not on Phusion Passenger, then set
1297
- <tt>RailsSpawnMethod</tt> to <em>conservative</em>. Otherwise, leave it at <em>smart</em> (the default).</p></div>
1734
+ <div class="paragraph"><p>If your application works on Mongrel, but not on Phusion Passenger, then set
1735
+ <tt>RailsSpawnMethod</tt> to <em>conservative</em>. Otherwise, leave it at <em>smart-lv2</em> (the default).</p></div>
1298
1736
  </div></div>
1299
- <div class="para"><p>However, we do recommend you to try to understand it. The <em>smart</em> spawn method brings
1300
- many benefits.</p></div>
1737
+ <div class="paragraph"><p>However, we do recommend you to try to understand it. The <em>smart</em> and <em>smart-lv2</em> spawn
1738
+ methods bring many benefits.</p></div>
1301
1739
  </td>
1302
1740
  </tr></table>
1303
1741
  </div>
1304
- <div class="para"><p>Internally, Phusion Passenger spawns multiple Ruby on Rails processes in order to handle
1742
+ <div class="paragraph"><p>Internally, Phusion Passenger spawns multiple Ruby on Rails processes in order to handle
1305
1743
  requests. But there are multiple ways with which processes can be spawned, each having
1306
1744
  its own set of pros and cons. Supported spawn methods are:</p></div>
1307
- <div class="vlist"><dl>
1308
- <dt>
1745
+ <div class="dlist"><dl>
1746
+ <dt class="hdlist1">
1309
1747
  <em>smart</em>
1310
1748
  </dt>
1311
1749
  <dd>
1312
1750
  <p>
1313
1751
  When this spawn method is used, Phusion Passenger will attempt to cache Ruby on Rails
1314
- framework code and application code for a limited period of time.
1752
+ framework code and application code for a limited period of time. Please read
1753
+ <a href="#spawning_methods_explained">Spawning methods explained</a> for a more detailed
1754
+ explanation of what smart spawning exactly does.
1315
1755
  </p>
1316
- <div class="para"><p><strong>Pros:</strong>
1756
+ <div class="paragraph"><p><strong>Pros:</strong>
1317
1757
  This can significantly decrease spawn time (by as much as 90%). And, when Ruby Enterprise
1318
1758
  Edition is used, <a href="#reducing_memory_usage">memory usage can be reduced by 33% on average</a>.</p></div>
1319
- <div class="para"><p><strong>Cons:</strong>
1759
+ <div class="paragraph"><p><strong>Cons:</strong>
1320
1760
  Some Ruby on Rails applications and libraries are not compatible with smart spawning.
1321
- If that's the case for your application, then you should use <em>conservative</em> as
1761
+ If that&#8217;s the case for your application, then you should use <em>conservative</em> as
1322
1762
  spawning method.</p></div>
1323
1763
  </dd>
1324
- <dt>
1764
+ <dt class="hdlist1">
1765
+ <em>smart-lv2</em>
1766
+ </dt>
1767
+ <dd>
1768
+ <p>
1769
+ This spawning method is similar to <em>smart</em> but it skips the framework spawner
1770
+ and uses the application spawner directly. This means the framework code is not
1771
+ cached between multiple applications, although it is still cached within
1772
+ instances of the same application. Please read
1773
+ <a href="#spawning_methods_explained">Spawning methods explained</a> for a more detailed
1774
+ explanation of what smart-lv2 spawning exactly does.
1775
+ </p>
1776
+ <div class="paragraph"><p><strong>Pros:</strong> It is compatible with a larger number of applications when compared to
1777
+ the <em>smart</em> method, and still performs some caching.</p></div>
1778
+ <div class="paragraph"><p><strong>Cons:</strong> It is slower than smart spawning if you have many applications which
1779
+ use the same framework version. It is therefore advised that shared hosts use the
1780
+ <em>smart</em> method instead.</p></div>
1781
+ </dd>
1782
+ <dt class="hdlist1">
1325
1783
  <em>conservative</em>
1326
1784
  </dt>
1327
1785
  <dd>
1328
1786
  <p>
1329
- This spawning method is similar to the one used in Mongrel Cluster. It does not perform
1330
- any code caching at all.
1787
+ This spawning method is similar to the one used in Mongrel Cluster. It does not
1788
+ perform any code caching at all. Please read
1789
+ <a href="#spawning_methods_explained">Spawning methods explained</a> for a more detailed
1790
+ explanation of what conservative spawning exactly does.
1331
1791
  </p>
1332
- <div class="para"><p><strong>Pros:</strong>
1792
+ <div class="paragraph"><p><strong>Pros:</strong>
1333
1793
  Conservative spawning is guaranteed to be compatible with all Rails applications
1334
1794
  and libraries.</p></div>
1335
- <div class="para"><p><strong>Cons:</strong>
1795
+ <div class="paragraph"><p><strong>Cons:</strong>
1336
1796
  Much slower than smart spawning. Every spawn action will be equally slow, though no slower than
1337
1797
  the startup time of a single server in Mongrel Cluster. Conservative spawning will also
1338
- render <a href="#reducing_memory_usage">Ruby Enterprise Edition's memory reduction technology</a> useless.</p></div>
1798
+ render <a href="#reducing_memory_usage">Ruby Enterprise Edition&#8217;s memory reduction technology</a> useless.</p></div>
1339
1799
  </dd>
1340
1800
  </dl></div>
1341
- <div class="para"><p>This option may occur once, in the global server configuration or in a virtual host
1342
- configuration block. The default value is <em>smart</em>.</p></div>
1343
- <h3 id="_rack_specific_options">5.9. Rack-specific options</h3><div style="clear:left"></div>
1344
- <h4 id="_rackautodetect_lt_on_off_gt">5.9.1. RackAutoDetect &lt;on|off&gt;</h4>
1345
- <div class="para"><p>Whether Phusion Passenger should automatically detect whether a virtual host's
1801
+ <div class="paragraph"><p>This option may occur in the following places:</p></div>
1802
+ <div class="ulist"><ul>
1803
+ <li>
1804
+ <p>
1805
+ In the global server configuration.
1806
+ </p>
1807
+ </li>
1808
+ <li>
1809
+ <p>
1810
+ In a virtual host configuration block.
1811
+ </p>
1812
+ </li>
1813
+ </ul></div>
1814
+ <div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>smart-lv2</em>.</p></div>
1815
+ <h4 id="_railsframeworkspawneridletime_lt_integer_gt">5.13.5. RailsFrameworkSpawnerIdleTime &lt;integer&gt;</h4>
1816
+ <div class="paragraph"><p>The FrameworkSpawner server (explained in <a href="#spawning_methods_explained">Spawning methods explained</a>) has an idle timeout, just like the backend processes spawned by
1817
+ Phusion Passenger do. That is, it will automatically shutdown if it hasn&#8217;t done
1818
+ anything for a given period.</p></div>
1819
+ <div class="paragraph"><p>This option allows you to set the FrameworkSpawner server&#8217;s idle timeout, in
1820
+ seconds. A value of <em>0</em> means that it should never idle timeout.</p></div>
1821
+ <div class="paragraph"><p>Setting a higher value will mean that the FrameworkSpawner server is kept around
1822
+ longer, which may slightly increase memory usage. But as long as the
1823
+ FrameworkSpawner server is running, the time to spawn a Ruby on Rails backend
1824
+ process only takes about 40% of the time that is normally needed, assuming that
1825
+ you&#8217;re using the <em>smart</em> <a href="#RailsSpawnMethod">spawning method</a>. So if your
1826
+ system has enough memory, is it recommended that you set this option to a high
1827
+ value or to <em>0</em>.</p></div>
1828
+ <div class="paragraph"><p>This option may only occur in the global server configuration, and may occur at
1829
+ most once. The default value is <em>1800</em> (30 minutes).</p></div>
1830
+ <h4 id="_railsappspawneridletime_lt_integer_gt">5.13.6. RailsAppSpawnerIdleTime &lt;integer&gt;</h4>
1831
+ <div class="paragraph"><p>The ApplicationSpawner server (explained in <a href="#spawning_methods_explained">Spawning methods explained</a>) has an idle timeout, just like the backend processes spawned by
1832
+ Phusion Passenger do. That is, it will automatically shutdown if it hasn&#8217;t done
1833
+ anything for a given period.</p></div>
1834
+ <div class="paragraph"><p>This option allows you to set the ApplicationSpawner server&#8217;s idle timeout, in
1835
+ seconds. A value of <em>0</em> means that it should never idle timeout.</p></div>
1836
+ <div class="paragraph"><p>Setting a higher value will mean that the ApplicationSpawner server is kept around
1837
+ longer, which may slightly increase memory usage. But as long as the
1838
+ ApplicationSpawner server is running, the time to spawn a Ruby on Rails backend
1839
+ process only takes about 10% of the time that is normally needed, assuming that
1840
+ you&#8217;re using the <em>smart</em> or <em>smart-lv2</em> <a href="#RailsSpawnMethod">spawning method</a>. So if your
1841
+ system has enough memory, is it recommended that you set this option to a high
1842
+ value or to <em>0</em>.</p></div>
1843
+ <div class="paragraph"><p>This option may only occur in the global server configuration, and may occur at
1844
+ most once. The default value is <em>600</em> (10 minutes).</p></div>
1845
+ <h3 id="_rack_specific_options">5.14. Rack-specific options</h3><div style="clear:left"></div>
1846
+ <h4 id="_rackautodetect_lt_on_off_gt">5.14.1. RackAutoDetect &lt;on|off&gt;</h4>
1847
+ <div class="paragraph"><p>Whether Phusion Passenger should automatically detect whether a virtual host&#8217;s
1346
1848
  document root is a Rack application. The default is <em>on</em>.</p></div>
1347
- <div class="para"><p>This option may occur in the global server configuration or in a virtual host
1849
+ <div class="paragraph"><p>This option may occur in the global server configuration or in a virtual host
1348
1850
  configuration block.</p></div>
1349
- <div class="para"><p>For example, consider the following configuration:</p></div>
1851
+ <div class="paragraph"><p>For example, consider the following configuration:</p></div>
1350
1852
  <div class="listingblock">
1351
1853
  <div class="content">
1352
1854
  <pre><tt>RackAutoDetect off
@@ -1355,10 +1857,10 @@ configuration block.</p></div>
1355
1857
  DocumentRoot /webapps/my_rack_app/public
1356
1858
  &lt;/VirtualHost&gt;</tt></pre>
1357
1859
  </div></div>
1358
- <div class="para"><p>If one goes to <em>http://www.rackapp.com/</em>, the visitor will see the contents of
1860
+ <div class="paragraph"><p>If one goes to <em>http://www.rackapp.com/</em>, the visitor will see the contents of
1359
1861
  the <em>/webapps/my_rack_app/public</em> folder, instead of the output of the Rack
1360
1862
  application.</p></div>
1361
- <div class="para"><p>It is possible to explicitly specify that the host is a Rack
1863
+ <div class="paragraph"><p>It is possible to explicitly specify that the host is a Rack
1362
1864
  application by using the <a href="#RackBaseURI">RackBaseURI</a> configuration option:</p></div>
1363
1865
  <div class="listingblock">
1364
1866
  <div class="content">
@@ -1369,37 +1871,82 @@ application by using the <a href="#RackBaseURI">RackBaseURI</a> configuration op
1369
1871
  RackBaseURI / # This line was added
1370
1872
  &lt;/VirtualHost&gt;</tt></pre>
1371
1873
  </div></div>
1372
- <h4 id="RackBaseURI">5.9.2. RackBaseURI &lt;uri&gt;</h4>
1373
- <div class="para"><p>Used to specify that the given URI is a Rack application. See
1874
+ <h4 id="RackBaseURI">5.14.2. RackBaseURI &lt;uri&gt;</h4>
1875
+ <div class="paragraph"><p>Used to specify that the given URI is a Rack application. See
1374
1876
  <a href="#deploying_rack_to_sub_uri">Deploying Rack to a sub URI</a> for an example.</p></div>
1375
- <div class="para"><p>It is allowed to specify this option multiple times. Do this to deploy multiple
1877
+ <div class="paragraph"><p>It is allowed to specify this option multiple times. Do this to deploy multiple
1376
1878
  Rack applications in different sub-URIs under the same virtual host.</p></div>
1377
- <div class="para"><p>This option may occur in the global server configuration or in a
1378
- virtual host configuration block.</p></div>
1379
- <h4 id="rack_env">5.9.3. RackEnv &lt;string&gt;</h4>
1380
- <div class="para"><p>The given value will be accessible in Rack applications in the <tt>RACK_ENV</tt>
1879
+ <div class="paragraph"><p>This option may occur in the following places:</p></div>
1880
+ <div class="ulist"><ul>
1881
+ <li>
1882
+ <p>
1883
+ In the global server configuration.
1884
+ </p>
1885
+ </li>
1886
+ <li>
1887
+ <p>
1888
+ In a virtual host configuration block.
1889
+ </p>
1890
+ </li>
1891
+ <li>
1892
+ <p>
1893
+ In a <tt>&lt;Directory&gt;</tt> or <tt>&lt;Location&gt;</tt> block.
1894
+ </p>
1895
+ </li>
1896
+ <li>
1897
+ <p>
1898
+ In <em>.htaccess</em>, if <tt>AllowOverride Options</tt> is on.
1899
+ </p>
1900
+ </li>
1901
+ </ul></div>
1902
+ <h4 id="rack_env">5.14.3. RackEnv &lt;string&gt;</h4>
1903
+ <div class="paragraph"><p>The given value will be accessible in Rack applications in the <tt>RACK_ENV</tt>
1381
1904
  environment variable. This allows one to define the environment in which
1382
1905
  Rack applications are run, very similar to <tt>RAILS_ENV</tt>.</p></div>
1383
- <div class="para"><p>This option may occur once, in the global server configuration or in a virtual host
1384
- configuration block. The default value is <em>production</em>.</p></div>
1385
- <h3 id="_deprecated_options">5.10. Deprecated options</h3><div style="clear:left"></div>
1386
- <div class="para"><p>The following options have been deprecated, but are still supported for backwards
1906
+ <div class="paragraph"><p>This option may occur in the following places:</p></div>
1907
+ <div class="ulist"><ul>
1908
+ <li>
1909
+ <p>
1910
+ In the global server configuration.
1911
+ </p>
1912
+ </li>
1913
+ <li>
1914
+ <p>
1915
+ In a virtual host configuration block.
1916
+ </p>
1917
+ </li>
1918
+ <li>
1919
+ <p>
1920
+ In a <tt>&lt;Directory&gt;</tt> or <tt>&lt;Location&gt;</tt> block.
1921
+ </p>
1922
+ </li>
1923
+ <li>
1924
+ <p>
1925
+ In <em>.htaccess</em>, if <tt>AllowOverride Options</tt> is on.
1926
+ </p>
1927
+ </li>
1928
+ </ul></div>
1929
+ <div class="paragraph"><p>In each place, it may be specified at most once. The default value is <em>production</em>.</p></div>
1930
+ <h3 id="_deprecated_options">5.15. Deprecated options</h3><div style="clear:left"></div>
1931
+ <div class="paragraph"><p>The following options have been deprecated, but are still supported for backwards
1387
1932
  compatibility reasons.</p></div>
1388
- <h4 id="_railsruby">5.10.1. RailsRuby</h4>
1389
- <div class="para"><p>Deprecated in favor of <a href="#PassengerRuby">PassengerRuby</a>.</p></div>
1390
- <h4 id="_railsuserswitching">5.10.2. RailsUserSwitching</h4>
1391
- <div class="para"><p>Deprecated in favor of <a href="#PassengerUserSwitching">PassengerUserSwitching</a>.</p></div>
1392
- <h4 id="_railsdefaultuser">5.10.3. RailsDefaultUser</h4>
1393
- <div class="para"><p>Deprecated in favor of <a href="#PassengerDefaultUser">PassengerDefaultUser</a>.</p></div>
1933
+ <h4 id="_railsruby">5.15.1. RailsRuby</h4>
1934
+ <div class="paragraph"><p>Deprecated in favor of <a href="#PassengerRuby">PassengerRuby</a>.</p></div>
1935
+ <h4 id="_railsuserswitching">5.15.2. RailsUserSwitching</h4>
1936
+ <div class="paragraph"><p>Deprecated in favor of <a href="#PassengerUserSwitching">PassengerUserSwitching</a>.</p></div>
1937
+ <h4 id="_railsdefaultuser">5.15.3. RailsDefaultUser</h4>
1938
+ <div class="paragraph"><p>Deprecated in favor of <a href="#PassengerDefaultUser">PassengerDefaultUser</a>.</p></div>
1939
+ <h4 id="_railsallowmodrewrite">5.15.4. RailsAllowModRewrite</h4>
1940
+ <div class="paragraph"><p>This option doesn&#8217;t do anything anymore in recent versions of Phusion Passenger.</p></div>
1394
1941
  </div>
1395
1942
  <h2 id="_troubleshooting">6. Troubleshooting</h2>
1396
1943
  <div class="sectionbody">
1397
1944
  <h3 id="_operating_system_specific_problems">6.1. Operating system-specific problems</h3><div style="clear:left"></div>
1398
- <h4 id="_macos_x_the_installer_cannot_locate_mamp_s_apache">6.1.1. MacOS X: The installer cannot locate MAMP's Apache</h4>
1945
+ <h4 id="_macos_x_the_installer_cannot_locate_mamp_8217_s_apache">6.1.1. MacOS X: The installer cannot locate MAMP&#8217;s Apache</h4>
1399
1946
  <div class="sidebarblock">
1400
1947
  <div class="sidebar-content">
1401
1948
  <div class="sidebar-title">Symptoms</div>
1402
- <div class="para"><p>The installer finds Apache 2 development headers at <tt>/Applications/MAMP/Library/bin/apxs</tt>.
1949
+ <div class="paragraph"><p>The installer finds Apache 2 development headers at <tt>/Applications/MAMP/Library/bin/apxs</tt>.
1403
1950
  However, Apache cannot be found. The installer also outputs the following error:</p></div>
1404
1951
  <div class="listingblock">
1405
1952
  <div class="content">
@@ -1407,26 +1954,26 @@ However, Apache cannot be found. The installer also outputs the following error:
1407
1954
  No such file or directory at /Applications/MAMP/Library/bin/apxs line 218.</tt></pre>
1408
1955
  </div></div>
1409
1956
  </div></div>
1410
- <div class="para"><p>Your MAMP installation seems to be broken. In particular, <em>config_vars.mk</em> is missing.
1957
+ <div class="paragraph"><p>Your MAMP installation seems to be broken. In particular, <em>config_vars.mk</em> is missing.
1411
1958
  Please read <a href="http://forum.mamp.info/viewtopic.php?t=1866">this forum topic</a> to learn how
1412
1959
  to fix this problem.</p></div>
1413
- <div class="para"><p>See also <a href="http://code.google.com/p/phusion-passenger/issues/detail?id=12">this bug report</a>.</p></div>
1960
+ <div class="paragraph"><p>See also <a href="http://code.google.com/p/phusion-passenger/issues/detail?id=12">this bug report</a>.</p></div>
1414
1961
  <h3 id="_problems_during_installation">6.2. Problems during installation</h3><div style="clear:left"></div>
1415
- <h4 id="installing_ruby_dev">6.2.1. Ruby development headers aren't installed</h4>
1962
+ <h4 id="installing_ruby_dev">6.2.1. Ruby development headers aren&#8217;t installed</h4>
1416
1963
  <div class="sidebarblock">
1417
1964
  <div class="sidebar-content">
1418
1965
  <div class="sidebar-title">Symptoms</div>
1419
- <div class="para"><p>Installing Phusion Passenger fails because of one of the following errors:</p></div>
1420
- <div class="ilist"><ul>
1966
+ <div class="paragraph"><p>Installing Phusion Passenger fails because of one of the following errors:</p></div>
1967
+ <div class="ulist"><ul>
1421
1968
  <li>
1422
1969
  <p>
1423
1970
  The Phusion Passenger installer tells you that the Ruby development headers
1424
- aren't installed.
1971
+ aren&#8217;t installed.
1425
1972
  </p>
1426
1973
  </li>
1427
1974
  <li>
1428
1975
  <p>
1429
- The error message &#8220;<em>no such file to load &#8212; mkmf&#8221;</em> occurs.
1976
+ The error message &#8220;<em>no such file to load&#8201;&#8212;&#8201;mkmf&#8221;</em> occurs.
1430
1977
  </p>
1431
1978
  </li>
1432
1979
  <li>
@@ -1436,13 +1983,13 @@ The error message &#8220;<em>ruby.h: No such file or directory&#8221;</em> occur
1436
1983
  </li>
1437
1984
  </ul></div>
1438
1985
  </div></div>
1439
- <div class="para"><p>Phusion Passenger makes use of a native extension, so the Ruby development headers
1986
+ <div class="paragraph"><p>Phusion Passenger makes use of a native extension, so the Ruby development headers
1440
1987
  must be installed. On most Linux systems, Ruby and the Ruby development headers
1441
1988
  are contained in separate packages, so having Ruby installed does not
1442
1989
  automatically imply having the development headers installed.</p></div>
1443
- <div class="para"><p>Here's how you can install the development headers:</p></div>
1444
- <div class="vlist"><dl>
1445
- <dt>
1990
+ <div class="paragraph"><p>Here&#8217;s how you can install the development headers:</p></div>
1991
+ <div class="dlist"><dl>
1992
+ <dt class="hdlist1">
1446
1993
  Ubuntu/Debian
1447
1994
  </dt>
1448
1995
  <dd>
@@ -1454,7 +2001,7 @@ Ubuntu/Debian
1454
2001
  <pre><tt>sudo apt-get install ruby1.8-dev</tt></pre>
1455
2002
  </div></div>
1456
2003
  </dd>
1457
- <dt>
2004
+ <dt class="hdlist1">
1458
2005
  Fedora/CentOS/RHEL
1459
2006
  </dt>
1460
2007
  <dd>
@@ -1466,7 +2013,7 @@ Fedora/CentOS/RHEL
1466
2013
  <pre><tt>su -c 'yum install ruby-devel'</tt></pre>
1467
2014
  </div></div>
1468
2015
  </dd>
1469
- <dt>
2016
+ <dt class="hdlist1">
1470
2017
  FreeBSD
1471
2018
  </dt>
1472
2019
  <dd>
@@ -1475,7 +2022,7 @@ FreeBSD
1475
2022
  please install Ruby from source.
1476
2023
  </p>
1477
2024
  </dd>
1478
- <dt>
2025
+ <dt class="hdlist1">
1479
2026
  MacOS X
1480
2027
  </dt>
1481
2028
  <dd>
@@ -1483,12 +2030,12 @@ MacOS X
1483
2030
  Please install Ruby from source.
1484
2031
  </p>
1485
2032
  </dd>
1486
- <dt>
2033
+ <dt class="hdlist1">
1487
2034
  Other operating systems
1488
2035
  </dt>
1489
2036
  <dd>
1490
2037
  <p>
1491
- Please consult your operating system's native package database.
2038
+ Please consult your operating system&#8217;s native package database.
1492
2039
  There should be a package containing the Ruby development headers.
1493
2040
  If that fails, please install Ruby from source.
1494
2041
  </p>
@@ -1499,34 +2046,34 @@ Other operating systems
1499
2046
  <td class="icon">
1500
2047
  <img src="./images/icons/note.png" alt="Note" />
1501
2048
  </td>
1502
- <td class="content">If you've installed a new Ruby version (i.e. your system now contains
2049
+ <td class="content">If you&#8217;ve installed a new Ruby version (i.e. your system now contains
1503
2050
  multiple Ruby installations), then you will need to tell Phusion Passenger
1504
2051
  which Ruby installation you want to use. Please read
1505
2052
  <a href="#specifying_ruby_installation">Specifying the correct Ruby installation</a>.</td>
1506
2053
  </tr></table>
1507
2054
  </div>
1508
- <h4 id="_apache_development_headers_aren_t_installed">6.2.2. Apache development headers aren't installed</h4>
2055
+ <h4 id="_apache_development_headers_aren_8217_t_installed">6.2.2. Apache development headers aren&#8217;t installed</h4>
1509
2056
  <div class="sidebarblock">
1510
2057
  <div class="sidebar-content">
1511
2058
  <div class="sidebar-title">Symptoms</div>
1512
- <div class="para"><p>Installing Phusion Passenger fails because of one of the following errors:</p></div>
1513
- <div class="ilist"><ul>
2059
+ <div class="paragraph"><p>Installing Phusion Passenger fails because of one of the following errors:</p></div>
2060
+ <div class="ulist"><ul>
1514
2061
  <li>
1515
2062
  <p>
1516
- The installer says that the Apache development headers aren't installed.
2063
+ The installer says that the Apache development headers aren&#8217;t installed.
1517
2064
  </p>
1518
2065
  </li>
1519
2066
  <li>
1520
2067
  <p>
1521
2068
  The error message &#8220;<em>httpd.h: No such file or directory&#8221;</em> occurs.
1522
2069
  </p>
1523
- <div class="para"><p>(Instead of <em>httpd.h</em>, the message might also be <em>http_config.h</em> or something
2070
+ <div class="paragraph"><p>(Instead of <em>httpd.h</em>, the message might also be <em>http_config.h</em> or something
1524
2071
  else similar to <em>http_*.h</em>.)</p></div>
1525
2072
  </li>
1526
2073
  </ul></div>
1527
2074
  </div></div>
1528
- <div class="vlist"><dl>
1529
- <dt>
2075
+ <div class="dlist"><dl>
2076
+ <dt class="hdlist1">
1530
2077
  Ubuntu
1531
2078
  </dt>
1532
2079
  <dd>
@@ -1538,7 +2085,7 @@ Ubuntu
1538
2085
  <pre><tt>sudo apt-get install apache2-prefork-dev</tt></pre>
1539
2086
  </div></div>
1540
2087
  </dd>
1541
- <dt>
2088
+ <dt class="hdlist1">
1542
2089
  Debian
1543
2090
  </dt>
1544
2091
  <dd>
@@ -1550,7 +2097,7 @@ Debian
1550
2097
  <pre><tt>sudo apt-get install apache2-dev</tt></pre>
1551
2098
  </div></div>
1552
2099
  </dd>
1553
- <dt>
2100
+ <dt class="hdlist1">
1554
2101
  Fedora/CentOS/RHEL
1555
2102
  </dt>
1556
2103
  <dd>
@@ -1562,7 +2109,7 @@ Fedora/CentOS/RHEL
1562
2109
  <pre><tt>su -c 'yum install httpd-devel'</tt></pre>
1563
2110
  </div></div>
1564
2111
  </dd>
1565
- <dt>
2112
+ <dt class="hdlist1">
1566
2113
  FreeBSD
1567
2114
  </dt>
1568
2115
  <dd>
@@ -1571,7 +2118,7 @@ FreeBSD
1571
2118
  please install Apache from source.
1572
2119
  </p>
1573
2120
  </dd>
1574
- <dt>
2121
+ <dt class="hdlist1">
1575
2122
  MacOS X
1576
2123
  </dt>
1577
2124
  <dd>
@@ -1579,26 +2126,26 @@ MacOS X
1579
2126
  Please install Apache from source.
1580
2127
  </p>
1581
2128
  </dd>
1582
- <dt>
2129
+ <dt class="hdlist1">
1583
2130
  Other operating systems
1584
2131
  </dt>
1585
2132
  <dd>
1586
2133
  <p>
1587
- Please consult your operating system's native package database.
2134
+ Please consult your operating system&#8217;s native package database.
1588
2135
  There should be a package containing the Apache development headers.
1589
2136
  If that fails, please install Apache from source.
1590
2137
  </p>
1591
2138
  </dd>
1592
2139
  </dl></div>
1593
- <h4 id="_apr_development_headers_aren_t_installed">6.2.3. APR development headers aren't installed</h4>
2140
+ <h4 id="_apr_development_headers_aren_8217_t_installed">6.2.3. APR development headers aren&#8217;t installed</h4>
1594
2141
  <div class="sidebarblock">
1595
2142
  <div class="sidebar-content">
1596
2143
  <div class="sidebar-title">Symptoms</div>
1597
- <div class="para"><p>Installing Phusion Passenger fails because one of the following errors:</p></div>
1598
- <div class="ilist"><ul>
2144
+ <div class="paragraph"><p>Installing Phusion Passenger fails because one of the following errors:</p></div>
2145
+ <div class="ulist"><ul>
1599
2146
  <li>
1600
2147
  <p>
1601
- The installer tells you that APR development headers aren't installed.
2148
+ The installer tells you that APR development headers aren&#8217;t installed.
1602
2149
  </p>
1603
2150
  </li>
1604
2151
  <li>
@@ -1613,8 +2160,8 @@ The error message &#8220;<em>apr_strings.h: No such file or directory&#8221;</em
1613
2160
  </li>
1614
2161
  </ul></div>
1615
2162
  </div></div>
1616
- <div class="vlist"><dl>
1617
- <dt>
2163
+ <div class="dlist"><dl>
2164
+ <dt class="hdlist1">
1618
2165
  Ubuntu
1619
2166
  </dt>
1620
2167
  <dd>
@@ -1626,7 +2173,7 @@ Ubuntu
1626
2173
  <pre><tt>sudo apt-get install libapr1-dev</tt></pre>
1627
2174
  </div></div>
1628
2175
  </dd>
1629
- <dt>
2176
+ <dt class="hdlist1">
1630
2177
  Debian
1631
2178
  </dt>
1632
2179
  <dd>
@@ -1638,7 +2185,7 @@ Debian
1638
2185
  <pre><tt>sudo apt-get install libapr1-dev</tt></pre>
1639
2186
  </div></div>
1640
2187
  </dd>
1641
- <dt>
2188
+ <dt class="hdlist1">
1642
2189
  Fedora/CentOS/RHEL
1643
2190
  </dt>
1644
2191
  <dd>
@@ -1650,30 +2197,30 @@ Fedora/CentOS/RHEL
1650
2197
  <pre><tt>su -c 'yum install apr-devel'</tt></pre>
1651
2198
  </div></div>
1652
2199
  </dd>
1653
- <dt>
2200
+ <dt class="hdlist1">
1654
2201
  Other Linux distributions
1655
2202
  </dt>
1656
2203
  <dd>
1657
2204
  <p>
1658
- Please consult your distribution's package database. There should be a
2205
+ Please consult your distribution&#8217;s package database. There should be a
1659
2206
  package which provides APR development headers.
1660
2207
  </p>
1661
2208
  </dd>
1662
- <dt>
2209
+ <dt class="hdlist1">
1663
2210
  Other operating systems
1664
2211
  </dt>
1665
2212
  <dd>
1666
2213
  <p>
1667
- The APR development are bundled with Apache. If the APR headers aren't,
1668
- then it probably means that they have been removed after Apache's been
2214
+ The APR development are bundled with Apache. If the APR headers aren&#8217;t,
2215
+ then it probably means that they have been removed after Apache&#8217;s been
1669
2216
  installed. Please reinstall Apache to get back the APR headers.
1670
2217
  </p>
1671
2218
  </dd>
1672
2219
  </dl></div>
1673
2220
  <h4 id="_phusion_passenger_is_using_the_wrong_apache_during_installation">6.2.4. Phusion Passenger is using the wrong Apache during installation</h4>
1674
- <div class="para"><p>Please <a href="#specifying_correct_apache_install">Specifying the correct Apache installation</a>, and re-run the Phusion Passenger installer.</p></div>
2221
+ <div class="paragraph"><p>Please <a href="#specifying_correct_apache_install">Specifying the correct Apache installation</a>, and re-run the Phusion Passenger installer.</p></div>
1675
2222
  <h4 id="_phusion_passenger_is_using_the_wrong_ruby_during_installation">6.2.5. Phusion Passenger is using the wrong Ruby during installation</h4>
1676
- <div class="para"><p>Please <a href="#specifying_ruby_installation">Specifying the correct Ruby installation</a>, and re-run the Phusion Passenger installer.</p></div>
2223
+ <div class="paragraph"><p>Please <a href="#specifying_ruby_installation">Specifying the correct Ruby installation</a>, and re-run the Phusion Passenger installer.</p></div>
1677
2224
  <h3 id="_problems_after_installation">6.3. Problems after installation</h3><div style="clear:left"></div>
1678
2225
  <div class="admonitionblock">
1679
2226
  <table><tr>
@@ -1682,31 +2229,31 @@ Other operating systems
1682
2229
  </td>
1683
2230
  <td class="content">
1684
2231
  <div class="title">The golden tip: read your Apache error logs!</div>
1685
- <div class="para"><p><em>mod_passenger</em> will write all errors to the Apache error log. So if
1686
- you're experiencing post-installation problems, please look
2232
+ <div class="paragraph"><p><em>mod_passenger</em> will write all errors to the Apache error log. So if
2233
+ you&#8217;re experiencing post-installation problems, please look
1687
2234
  inside the Apache error logs. It will tell you what exactly went wrong.</p></div>
1688
2235
  </td>
1689
2236
  </tr></table>
1690
2237
  </div>
1691
2238
  <h4 id="_my_rails_application_works_on_mongrel_but_not_on_phusion_passenger">6.3.1. My Rails application works on Mongrel, but not on Phusion Passenger</h4>
1692
- <div class="para"><p>Please try setting <a href="#RailsSpawnMethod">RailsSpawnMethod</a> to <em>conservative</em>.</p></div>
2239
+ <div class="paragraph"><p>Please try setting <a href="#RailsSpawnMethod">RailsSpawnMethod</a> to <em>conservative</em>.</p></div>
1693
2240
  <h4 id="_phusion_passenger_has_been_compiled_against_the_wrong_apache_installation">6.3.2. Phusion Passenger has been compiled against the wrong Apache installation</h4>
1694
2241
  <div class="sidebarblock">
1695
2242
  <div class="sidebar-content">
1696
2243
  <div class="sidebar-title">Symptoms</div>
1697
- <div class="para"><p>Apache crashes during startup (after being daemonized). The Apache error log
2244
+ <div class="paragraph"><p>Apache crashes during startup (after being daemonized). The Apache error log
1698
2245
  says &#8220;<em>seg fault or similar nasty error detected in the parent process&#8221;</em>.</p></div>
1699
2246
  </div></div>
1700
- <div class="para"><p>This problem is most likely to occur on MacOS X. Most OS X users have multiple
2247
+ <div class="paragraph"><p>This problem is most likely to occur on MacOS X. Most OS X users have multiple
1701
2248
  Apache installations on their system.</p></div>
1702
- <div class="para"><p>To solve this problem, please <a href="#specifying_correct_apache_install">specify the correct Apache installation</a>, and <a href="#install_passenger">reinstall Phusion Passenger</a>.</p></div>
2249
+ <div class="paragraph"><p>To solve this problem, please <a href="#specifying_correct_apache_install">specify the correct Apache installation</a>, and <a href="#install_passenger">reinstall Phusion Passenger</a>.</p></div>
1703
2250
  <h4 id="_i_get_a_304_forbidden_error">6.3.3. I get a "304 Forbidden" error</h4>
1704
- <div class="para"><p>See next subsection.</p></div>
1705
- <h4 id="_static_assets_such_as_images_and_stylesheets_aren_t_being_displayed">6.3.4. Static assets such as images and stylesheets aren't being displayed</h4>
1706
- <div class="para"><p>Static assets are accelerated, i.e. they are served directly by Apache and do not
1707
- go through the Rails stack. There are two reasons why Apache doesn't serve static
2251
+ <div class="paragraph"><p>See next subsection.</p></div>
2252
+ <h4 id="_static_assets_such_as_images_and_stylesheets_aren_8217_t_being_displayed">6.3.4. Static assets such as images and stylesheets aren&#8217;t being displayed</h4>
2253
+ <div class="paragraph"><p>Static assets are accelerated, i.e. they are served directly by Apache and do not
2254
+ go through the Rails stack. There are two reasons why Apache doesn&#8217;t serve static
1708
2255
  assets correctly:</p></div>
1709
- <div class="olist"><ol>
2256
+ <div class="olist arabic"><ol class="arabic">
1710
2257
  <li>
1711
2258
  <p>
1712
2259
  Your Apache configuration is too strict, and does not allow HTTP clients to
@@ -1722,44 +2269,44 @@ Your Apache configuration is too strict, and does not allow HTTP clients to
1722
2269
  Allow from all
1723
2270
  &lt;/Directory&gt;</tt></pre>
1724
2271
  </div></div>
1725
- <div class="para"><p>See also <a href="http://groups.google.com/group/phusion-passenger/browse_thread/thread/9699a639a87f85f4/b9d71a03bf2670a5">this discussion</a>.</p></div>
2272
+ <div class="paragraph"><p>See also <a href="http://groups.google.com/group/phusion-passenger/browse_thread/thread/9699a639a87f85f4/b9d71a03bf2670a5">this discussion</a>.</p></div>
1726
2273
  </li>
1727
2274
  <li>
1728
2275
  <p>
1729
- The Apache process doesn't have permission to access your Rails application's folder.
1730
- Please make sure that the Rails application's folder, as well as all of its parent folders,
2276
+ The Apache process doesn&#8217;t have permission to access your Rails application&#8217;s folder.
2277
+ Please make sure that the Rails application&#8217;s folder, as well as all of its parent folders,
1731
2278
  have the correct permissions and/or ownerships.
1732
2279
  </p>
1733
2280
  </li>
1734
2281
  </ol></div>
1735
2282
  <h4 id="_the_apache_error_log_says_that_the_spawn_manager_script_does_not_exist_or_that_it_does_not_have_permission_to_execute_it">6.3.5. The Apache error log says that the spawn manager script does not exist, or that it does not have permission to execute it</h4>
1736
- <div class="para"><p>If you are sure that the <em>PassengerRoot</em> configuration option is set correctly,
1737
- then this problem is most likely caused by the fact that you're running Apache
2283
+ <div class="paragraph"><p>If you are sure that the <em>PassengerRoot</em> configuration option is set correctly,
2284
+ then this problem is most likely caused by the fact that you&#8217;re running Apache
1738
2285
  with SELinux. On Fedora, CentOS and RedHat Enterprise Linux, Apache is locked
1739
2286
  down by SELinux policies.</p></div>
1740
- <div class="para"><p>To solve this problem, you must set some permissions on the Phusion Passenger files
2287
+ <div class="paragraph"><p>To solve this problem, you must set some permissions on the Phusion Passenger files
1741
2288
  and folders, so that Apache can access them.</p></div>
1742
- <div class="ilist"><ul>
2289
+ <div class="ulist"><ul>
1743
2290
  <li>
1744
2291
  <p>
1745
- If you've installed Phusion Passenger via a gem, then run this command to determine
1746
- Phusion Passenger's root folder:
2292
+ If you&#8217;ve installed Phusion Passenger via a gem, then run this command to determine
2293
+ Phusion Passenger&#8217;s root folder:
1747
2294
  </p>
1748
2295
  <div class="listingblock">
1749
2296
  <div class="content">
1750
2297
  <pre><tt>passenger-config --root</tt></pre>
1751
2298
  </div></div>
1752
- <div class="para"><p>Next, run the following command:</p></div>
2299
+ <div class="paragraph"><p>Next, run the following command:</p></div>
1753
2300
  <div class="listingblock">
1754
2301
  <div class="content">
1755
2302
  <pre><tt>chcon -R -h -t httpd_sys_content_t /path-to-passenger-root</tt></pre>
1756
2303
  </div></div>
1757
- <div class="para"><p>where <em>/path-to-passenger-root</em> should be replaced with whatever
1758
- <tt>passenger-config &#8212;root</tt> printed.</p></div>
2304
+ <div class="paragraph"><p>where <em>/path-to-passenger-root</em> should be replaced with whatever
2305
+ <tt>passenger-config --root</tt> printed.</p></div>
1759
2306
  </li>
1760
2307
  <li>
1761
2308
  <p>
1762
- If you've installed Phusion Passenger via the source tarball, then run the following
2309
+ If you&#8217;ve installed Phusion Passenger via the source tarball, then run the following
1763
2310
  command:
1764
2311
  </p>
1765
2312
  <div class="listingblock">
@@ -1768,18 +2315,18 @@ If you've installed Phusion Passenger via the source tarball, then run the follo
1768
2315
  </div></div>
1769
2316
  </li>
1770
2317
  </ul></div>
1771
- <div class="para"><p>Once the permissions are fixed, restart Apache.</p></div>
1772
- <h4 id="_the_rails_application_reports_that_it_s_unable_to_start_because_of_a_permission_error">6.3.6. The Rails application reports that it's unable to start because of a permission error</h4>
1773
- <div class="para"><p>Please check whether your Rails application's folder has the correct
2318
+ <div class="paragraph"><p>Once the permissions are fixed, restart Apache.</p></div>
2319
+ <h4 id="_the_rails_application_reports_that_it_8217_s_unable_to_start_because_of_a_permission_error">6.3.6. The Rails application reports that it&#8217;s unable to start because of a permission error</h4>
2320
+ <div class="paragraph"><p>Please check whether your Rails application&#8217;s folder has the correct
1774
2321
  permissions. By default, Rails applications are started as the owner of the
1775
2322
  file <em>config/environment.rb</em>, except if the file is owned by root. If the
1776
2323
  file is owned by root, then the Rails application will be started as <em>nobody</em>
1777
- (or as the user specify by <a href="#RailsDefaultUser">RailsDefaultUser</a>, if that's
2324
+ (or as the user specify by <a href="#RailsDefaultUser">RailsDefaultUser</a>, if that&#8217;s
1778
2325
  specified).</p></div>
1779
- <div class="para"><p>Please read <a href="#user_switching">User switching (security)</a> for details.</p></div>
1780
- <h4 id="_my_rails_application_s_log_file_is_not_being_written_to">6.3.7. My Rails application's log file is not being written to</h4>
1781
- <div class="para"><p>There are a couple things that you should be aware of:</p></div>
1782
- <div class="ilist"><ul>
2326
+ <div class="paragraph"><p>Please read <a href="#user_switching">User switching (security)</a> for details.</p></div>
2327
+ <h4 id="_my_rails_application_8217_s_log_file_is_not_being_written_to">6.3.7. My Rails application&#8217;s log file is not being written to</h4>
2328
+ <div class="paragraph"><p>There are a couple things that you should be aware of:</p></div>
2329
+ <div class="ulist"><ul>
1783
2330
  <li>
1784
2331
  <p>
1785
2332
  By default, Phusion Passenger runs Rails applications in <em>production</em> mode,
@@ -1793,12 +2340,12 @@ By default, Phusion Passenger runs Rails applications as the owner of <em>enviro
1793
2340
  So the log file can only be written to if that user has write permission to the
1794
2341
  log file. Please <em>chmod</em> or <em>chown</em> your log file accordingly.
1795
2342
  </p>
1796
- <div class="para"><p>See <a href="#User_switching">User switching (security)</a> for details.</p></div>
2343
+ <div class="paragraph"><p>See <a href="#User_switching">User switching (security)</a> for details.</p></div>
1797
2344
  </li>
1798
2345
  </ul></div>
1799
- <div class="para"><p>If you're using a RedHat-derived Linux distribution (such as Fedora or CentOS)
2346
+ <div class="paragraph"><p>If you&#8217;re using a RedHat-derived Linux distribution (such as Fedora or CentOS)
1800
2347
  then it is <a href="http://code.google.com/p/phusion-passenger/issues/detail?id=4">possible
1801
- that SELinux is interfering</a>. RedHat's SELinux policy only allows Apache to read/write
2348
+ that SELinux is interfering</a>. RedHat&#8217;s SELinux policy only allows Apache to read/write
1802
2349
  directories that have the <em>httpd_sys_content_t</em> security context. Please run the
1803
2350
  following command to give your Rails application folder that context:</p></div>
1804
2351
  <div class="listingblock">
@@ -1806,46 +2353,24 @@ following command to give your Rails application folder that context:</p></div>
1806
2353
  <pre><tt>chcon -R -h -t httpd_sys_content_t /path/to/your/rails/app</tt></pre>
1807
2354
  </div></div>
1808
2355
  <h3 id="conflicting_apache_modules">6.4. Conflicting Apache modules</h3><div style="clear:left"></div>
1809
- <h4 id="_mod_rewrite_and_mod_alias">6.4.1. mod_rewrite and mod_alias</h4>
1810
- <div class="para"><p>Phusion Passenger conflicts with <em>mod_rewrite</em> and <em>mod_alias</em>. Those modules may be
1811
- installed and loaded together with <em>mod_passenger</em>, and they will work fine
1812
- outside virtual hosts that contain a Rails application, but we recommend you
1813
- not to use their features inside virtual hosts that contain a Rails
1814
- application.</p></div>
1815
- <div class="para"><p>By default, Phusion Passenger will override mod_rewrite rules on Rails hosts.
1816
- This is because the default .htaccess, as provided by Ruby on Rails, redirects all
1817
- requests to `dispatch.cgi' using mod_rewrite. This is a CGI application which
1818
- loads the entire Ruby on Rails framework for every request, and thus is very
1819
- slow. If we do not override mod_rewrite, then Ruby on Rails apps will be slow
1820
- on Phusion Passenger by default &#8212; but we want a good out-of-the-box experience.</p></div>
1821
- <div class="para"><p>Furthermore, the primary reason why people use mod_rewrite with Rails
1822
- applications, is to accelerate page caching. Phusion Passenger supports page
1823
- caching out-of-the-box, without mod_rewrite.</p></div>
1824
- <div class="para"><p>It is not fully understood how mod_alias conflicts with Phusion Passenger, but we
1825
- recommend you not to use it on Rails virtual hosts. mod_alias rules can result
1826
- in surprising problems.</p></div>
1827
- <div class="para"><p>If you really want to use mod_rewrite on Rails virtual hosts, then please set
1828
- the <a href="#RailsAllowModRewrite">RailsAllowModRewrite</a> configuration option. But
1829
- please note that you will have to delete Rails applications' default .htaccess
1830
- file, or add rewrite rules to negate its effects.</p></div>
1831
- <h4 id="_mod_userdir">6.4.2. mod_userdir</h4>
1832
- <div class="para"><p><em>mod_userdir</em> is not compatible with Phusion Passenger at the moment.</p></div>
1833
- <h4 id="_virtualdocumentroot">6.4.3. VirtualDocumentRoot</h4>
1834
- <div class="para"><p>VirtualDocumentRoot is not compatible with Phusion Passenger at the moment.</p></div>
2356
+ <h4 id="_mod_userdir">6.4.1. mod_userdir</h4>
2357
+ <div class="paragraph"><p><em>mod_userdir</em> is not compatible with Phusion Passenger at the moment.</p></div>
2358
+ <h4 id="_virtualdocumentroot">6.4.2. VirtualDocumentRoot</h4>
2359
+ <div class="paragraph"><p>VirtualDocumentRoot is not compatible with Phusion Passenger at the moment.</p></div>
1835
2360
  </div>
1836
2361
  <h2 id="_analysis_and_system_maintenance_tools">7. Analysis and system maintenance tools</h2>
1837
2362
  <div class="sectionbody">
1838
- <div class="para"><p>Phusion Passenger provides a set of tools, which are useful for system analysis,
2363
+ <div class="paragraph"><p>Phusion Passenger provides a set of tools, which are useful for system analysis,
1839
2364
  maintenance and troubleshooting.</p></div>
1840
2365
  <h3 id="_inspecting_memory_usage">7.1. Inspecting memory usage</h3><div style="clear:left"></div>
1841
- <div class="para"><p>Process inspection tools such as <tt>ps</tt> and <tt>top</tt> are useful, but they
2366
+ <div class="paragraph"><p>Process inspection tools such as <tt>ps</tt> and <tt>top</tt> are useful, but they
1842
2367
  <a href="http://groups.google.com/group/phusion-passenger/msg/1fd1c233456d3180">rarely show the correct memory usage</a>.
1843
2368
  The real memory usage is usually lower than what <tt>ps</tt> and <tt>top</tt> report.</p></div>
1844
- <div class="para"><p>There are many technical reasons why this is so, but an explanation is beyond
2369
+ <div class="paragraph"><p>There are many technical reasons why this is so, but an explanation is beyond
1845
2370
  the scope of this Users Guide. We kindly refer the interested reader to
1846
2371
  operating systems literature about <em>virtual memory</em> and <em>copy-on-write</em>.</p></div>
1847
- <div class="para"><p>The tool <tt>passenger-memory-stats</tt> allows one to easily analyze Phusion Passenger's
1848
- and Apache's real memory usage. For example:</p></div>
2372
+ <div class="paragraph"><p>The tool <tt>passenger-memory-stats</tt> allows one to easily analyze Phusion Passenger&#8217;s
2373
+ and Apache&#8217;s real memory usage. For example:</p></div>
1849
2374
  <div class="listingblock">
1850
2375
  <div class="content">
1851
2376
  <pre><tt>[bash@localhost root]# passenger-memory-stats
@@ -1873,7 +2398,7 @@ PID Threads VMSize Private Name
1873
2398
  ### Processes: 4
1874
2399
  ### Total private dirty RSS: 27.76 M</tt></pre>
1875
2400
  </div></div>
1876
- <div class="para"><p>The <em>Private</em> or <em>private dirty RSS</em> field shows the <strong>real</strong> memory usage of processes. Here,
2401
+ <div class="paragraph"><p>The <em>Private</em> or <em>private dirty RSS</em> field shows the <strong>real</strong> memory usage of processes. Here,
1877
2402
  we see that all the Apache worker processes only take less than 1 MB memory each.
1878
2403
  This is a lot less than the 50 MB-ish memory usage as shown in the <em>VMSize</em> column
1879
2404
  (which is what a lot of people think is the real memory usage, but is actually not).</p></div>
@@ -1882,12 +2407,12 @@ This is a lot less than the 50 MB-ish memory usage as shown in the <em>VMSize</e
1882
2407
  <td class="icon">
1883
2408
  <img src="./images/icons/note.png" alt="Note" />
1884
2409
  </td>
1885
- <td class="content">This tool only works on Linux. Unfortunately other operating systems don't
2410
+ <td class="content">This tool only works on Linux. Unfortunately other operating systems don&#8217;t
1886
2411
  provide facilities for determining processes' private dirty RSS.</td>
1887
2412
  </tr></table>
1888
2413
  </div>
1889
- <h3 id="_inspecting_phusion_passenger_s_internal_status">7.2. Inspecting Phusion Passenger's internal status</h3><div style="clear:left"></div>
1890
- <div class="para"><p>One can inspect Phusion Passenger's internal status with the tool <tt>passenger-status</tt>.
2414
+ <h3 id="_inspecting_phusion_passenger_8217_s_internal_status">7.2. Inspecting Phusion Passenger&#8217;s internal status</h3><div style="clear:left"></div>
2415
+ <div class="paragraph"><p>One can inspect Phusion Passenger&#8217;s internal status with the tool <tt>passenger-status</tt>.
1891
2416
  This tool must typically be run as root. For example:</p></div>
1892
2417
  <div class="listingblock">
1893
2418
  <div class="content">
@@ -1898,75 +2423,106 @@ count = 1
1898
2423
  active = 0
1899
2424
  inactive = 1
1900
2425
 
1901
- ----------- Applications -----------
2426
+ ----------- Domains -----------
1902
2427
  /var/www/projects/app1-foobar:
1903
- PID: 9617 Sessions: 0</tt></pre>
2428
+ PID: 9617 Sessions: 0 Processed: 7 Uptime: 2m 23s</tt></pre>
1904
2429
  </div></div>
1905
- <div class="para"><p>The <em>general information</em> section shows the following information:</p></div>
1906
- <div class="hlist"><table>
1907
- <tr>
1908
- <td class="hlist1">
2430
+ <div class="paragraph"><p>The <em>general information</em> section shows the following information:</p></div>
2431
+ <div class="dlist"><dl>
2432
+ <dt class="hdlist1">
1909
2433
  max
1910
- </td>
1911
- <td class="hlist2">
2434
+ </dt>
2435
+ <dd>
2436
+ <p>
1912
2437
  The maximum number of application instances that Phusion Passenger will
1913
2438
  spawn. This equals the value given for <a href="#PassengerMaxPoolSize">PassengerMaxPoolSize</a>.
1914
- </td>
1915
- </tr>
1916
- <tr>
1917
- <td class="hlist1">
2439
+ </p>
2440
+ </dd>
2441
+ <dt class="hdlist1">
1918
2442
  count
1919
- </td>
1920
- <td class="hlist2">
2443
+ </dt>
2444
+ <dd>
2445
+ <p>
1921
2446
  The number of application instances that are currently alive. This value
1922
2447
  is always less than or equal to <em>max</em>.
1923
- </td>
1924
- </tr>
1925
- <tr>
1926
- <td class="hlist1">
2448
+ </p>
2449
+ </dd>
2450
+ <dt class="hdlist1">
1927
2451
  active
1928
- </td>
1929
- <td class="hlist2">
2452
+ </dt>
2453
+ <dd>
2454
+ <p>
1930
2455
  The number of application instances that are currently processing
1931
2456
  requests. This value is always less than or equal to <em>count</em>.
1932
- </td>
1933
- </tr>
1934
- <tr>
1935
- <td class="hlist1">
2457
+ </p>
2458
+ </dd>
2459
+ <dt class="hdlist1">
1936
2460
  inactive
1937
- </td>
1938
- <td class="hlist2">
2461
+ </dt>
2462
+ <dd>
2463
+ <p>
1939
2464
  The number of application instances that are currently <strong>not</strong> processing
1940
2465
  requests, i.e. are idle. Idle application instances will be shutdown after a while,
1941
- as can be specified with <a href="#PassengerPoolIdleTime">PassengerPoolIdleTime</a>. The value of <em>inactive</em>
1942
- equals <tt>count - active</tt>.
1943
- </td>
1944
- </tr>
1945
- </table></div>
1946
- <div class="para"><p>The <em>applications</em> section shows each application instance, which directory it belongs
1947
- to. The <em>sessions</em> field shows how many HTTP client are currently being processed by
1948
- that application instance.</p></div>
1949
- <div class="para"><p>Since Phusion Passenger uses fair load balancing by default, the number of sessions for the
2466
+ as can be specified with <a href="#PassengerPoolIdleTime">PassengerPoolIdleTime</a> (unless this
2467
+ value is set to 0, in which case application instances are never shut down via idle
2468
+ time). The value of <em>inactive</em> equals <tt>count - active</tt>.
2469
+ </p>
2470
+ </dd>
2471
+ </dl></div>
2472
+ <div class="paragraph"><p>The <em>domains</em> section shows, for each application directory, information about running
2473
+ application instances:</p></div>
2474
+ <div class="dlist"><dl>
2475
+ <dt class="hdlist1">
2476
+ Sessions
2477
+ </dt>
2478
+ <dd>
2479
+ <p>
2480
+ Shows how many HTTP client are currently in the queue of that application
2481
+ Instance, waiting to be processed.
2482
+ </p>
2483
+ </dd>
2484
+ <dt class="hdlist1">
2485
+ Processed
2486
+ </dt>
2487
+ <dd>
2488
+ <p>
2489
+ Indicates how many requests the instance has served until now. <strong>Tip:</strong> it&#8217;s
2490
+ possible to limit this number with the <a href="#PassengerMaxRequests">PassengerMaxRequests</a>
2491
+ configuration directive.
2492
+ </p>
2493
+ </dd>
2494
+ <dt class="hdlist1">
2495
+ Uptime
2496
+ </dt>
2497
+ <dd>
2498
+ <p>
2499
+ Shows for how long the application instance has been running.
2500
+ </p>
2501
+ </dd>
2502
+ </dl></div>
2503
+ <div class="paragraph"><p>Since Phusion Passenger uses fair load balancing by default, the number of sessions for the
1950
2504
  application instances should be fairly close to each other. For example, this is fairly
1951
2505
  normal:</p></div>
1952
2506
  <div class="listingblock">
1953
2507
  <div class="content">
1954
- <pre><tt> PID: 4281 Sessions: 2
1955
- PID: 4268 Sessions: 0
1956
- PID: 4265 Sessions: 1
1957
- PID: 4275 Sessions: 1</tt></pre>
2508
+ <pre><tt> PID: 4281 Sessions: 2 Processed: 7 Uptime: 5m 11s
2509
+ PID: 4268 Sessions: 0 Processed: 5 Uptime: 4m 52s
2510
+ PID: 4265 Sessions: 1 Processed: 6 Uptime: 5m 38s
2511
+ PID: 4275 Sessions: 1 Processed: 7 Uptime: 3m 14s</tt></pre>
1958
2512
  </div></div>
1959
- <div class="para"><p>But if you see a "spike", i.e. an application instance has an unusually high number of
2513
+ <div class="paragraph"><p>But if you see a "spike", i.e. an application instance has an unusually high number of
1960
2514
  sessions compared to the others, then there might be a problem:</p></div>
1961
2515
  <div class="listingblock">
1962
2516
  <div class="content">
1963
- <pre><tt> PID: 4281 Sessions: 2
1964
- PID: 17468 Sessions: 8 &lt;---- "spike"
1965
- PID: 4265 Sessions: 1
1966
- PID: 4275 Sessions: 1</tt></pre>
1967
- </div></div>
1968
- <div class="para"><p>Possible reasons why spikes can occur:</p></div>
1969
- <div class="olist"><ol>
2517
+ <pre><tt> PID: 4281 Sessions: 2 Processed: 7 Uptime: 5m 11s
2518
+ PID: 17468 Sessions: 8 &lt;-+ Processed: 2 Uptime: 4m 47s
2519
+ PID: 4265 Sessions: 1 | Processed: 6 Uptime: 5m 38s
2520
+ PID: 4275 Sessions: 1 | Processed: 7 Uptime: 3m 14s
2521
+ |
2522
+ +---- "spike"</tt></pre>
2523
+ </div></div>
2524
+ <div class="paragraph"><p>Possible reasons why spikes can occur:</p></div>
2525
+ <div class="olist arabic"><ol class="arabic">
1970
2526
  <li>
1971
2527
  <p>
1972
2528
  Your application is busy processing a request that takes a very long time.
@@ -1982,15 +2538,15 @@ Your application is frozen, i.e. has stopped responding. See
1982
2538
  </li>
1983
2539
  </ol></div>
1984
2540
  <h3 id="debugging_frozen">7.3. Debugging frozen applications</h3><div style="clear:left"></div>
1985
- <div class="para"><p>If one of your application instances is frozen (stopped responding), then you
2541
+ <div class="paragraph"><p>If one of your application instances is frozen (stopped responding), then you
1986
2542
  can figure out where it is frozen by killing it with <em>SIGABRT</em>. This will cause the
1987
2543
  application to raise an exception, with a backtrace.</p></div>
1988
- <div class="para"><p>The exception (with full backtrace information) is normally logged into the Apache
2544
+ <div class="paragraph"><p>The exception (with full backtrace information) is normally logged into the Apache
1989
2545
  error log. But if your application or if its web framework has its own exception logging
1990
- routines, then exceptions might be logged into the application's log files instead.
2546
+ routines, then exceptions might be logged into the application&#8217;s log files instead.
1991
2547
  This is the case with Ruby on Rails. So if you kill a Ruby on Rails application with
1992
- <em>SIGABRT</em>, please check the application's <em>production.log</em> first (assuming that you're
1993
- running it in a <em>production</em> environment). If you don't see a backtrace there, check
2548
+ <em>SIGABRT</em>, please check the application&#8217;s <em>production.log</em> first (assuming that you&#8217;re
2549
+ running it in a <em>production</em> environment). If you don&#8217;t see a backtrace there, check
1994
2550
  the Apache error log.</p></div>
1995
2551
  <div class="admonitionblock">
1996
2552
  <table><tr>
@@ -2005,23 +2561,23 @@ will restart killed application instances, as if nothing bad happened.</td>
2005
2561
  <h2 id="_tips">8. Tips</h2>
2006
2562
  <div class="sectionbody">
2007
2563
  <h3 id="user_switching">8.1. User switching (security)</h3><div style="clear:left"></div>
2008
- <div class="para"><p>There is a problem that plagues most PHP web host, namely the fact that all PHP
2564
+ <div class="paragraph"><p>There is a problem that plagues most PHP web hosts, namely the fact that all PHP
2009
2565
  applications are run in the same user context as the web server. So for
2010
- example, Joe's PHP application will be able to read Jane's PHP application's
2566
+ example, Joe&#8217;s PHP application will be able to read Jane&#8217;s PHP application&#8217;s
2011
2567
  passwords. This is obviously undesirable on many servers.</p></div>
2012
- <div class="para"><p>Phusion Passenger solves this problem by implementing <em>user switching</em>. A Rails
2568
+ <div class="paragraph"><p>Phusion Passenger solves this problem by implementing <em>user switching</em>. A Rails
2013
2569
  application is started as the owner of the file <em>config/environment.rb</em>,
2014
2570
  and a Rack application is started as the owner of the file <em>config.ru</em>.
2015
2571
  So if <em>/home/webapps/foo/config/environment.rb</em> is owned by <em>joe</em>, then Phusion
2016
2572
  Passenger will launch the corresponding Rails application as <em>joe</em> as well.</p></div>
2017
- <div class="para"><p>This behavior is the default, and you don't need to configure anything. But
2573
+ <div class="paragraph"><p>This behavior is the default, and you don&#8217;t need to configure anything. But
2018
2574
  there are things that you should keep in mind:</p></div>
2019
- <div class="ilist"><ul>
2575
+ <div class="ulist"><ul>
2020
2576
  <li>
2021
2577
  <p>
2022
- The owner of <em>environment.rb</em> must have read access to the Rails application's
2023
- folder, and read/write access to the Rails application's <em>logs</em> folder.
2024
- Likewise, the owner of <em>config.ru</em> must have read access to the Rack application's
2578
+ The owner of <em>environment.rb</em> must have read access to the Rails application&#8217;s
2579
+ folder, and read/write access to the Rails application&#8217;s <em>logs</em> folder.
2580
+ Likewise, the owner of <em>config.ru</em> must have read access to the Rack application&#8217;s
2025
2581
  folder.
2026
2582
  </p>
2027
2583
  </li>
@@ -2040,17 +2596,17 @@ Under no circumstances will applications be run as <em>root</em>. If
2040
2596
  </p>
2041
2597
  </li>
2042
2598
  </ul></div>
2043
- <div class="para"><p>User switching can be disabled with the
2599
+ <div class="paragraph"><p>User switching can be disabled with the
2044
2600
  <a href="#PassengerUserSwitching">PassengerUserSwitching</a> option.</p></div>
2045
2601
  <h3 id="reducing_memory_usage">8.2. Reducing memory consumption of Ruby on Rails applications by 33%</h3><div style="clear:left"></div>
2046
- <div class="para"><p>Is it possible to reduce memory consumption of your Rails applications by 33% on average,
2602
+ <div class="paragraph"><p>Is it possible to reduce memory consumption of your Rails applications by 33% on average,
2047
2603
  by using <a href="http://www.rubyenterpriseedition.com/">Ruby Enterprise Edition</a>.
2048
2604
  Please visit the website for details.</p></div>
2049
- <div class="para"><p>Note that this feature does not apply to Rack applications.</p></div>
2605
+ <div class="paragraph"><p>Note that this feature does not apply to Rack applications.</p></div>
2050
2606
  <h3 id="capistrano">8.3. Capistrano recipe</h3><div style="clear:left"></div>
2051
- <div class="para"><p>Phusion Passenger can be combined with <a href="http://capify.org/">Capistrano</a>.
2607
+ <div class="paragraph"><p>Phusion Passenger can be combined with <a href="http://capify.org/">Capistrano</a>.
2052
2608
  The following Capistrano recipe demonstrates Phusion Passenger support.
2053
- It assumes that you're using Git as version control system.</p></div>
2609
+ It assumes that you&#8217;re using Git as version control system.</p></div>
2054
2610
  <div class="listingblock">
2055
2611
  <div class="content">
2056
2612
  <pre><tt>set :application, "myapp"
@@ -2065,48 +2621,48 @@ role :web, domain
2065
2621
  role :db, domain, :primary =&gt; true
2066
2622
 
2067
2623
  namespace :deploy do
2624
+ task :start, :roles =&gt; :app do
2625
+ run "touch #{current_release}/tmp/restart.txt"
2626
+ end
2627
+
2628
+ task :stop, :roles =&gt; :app do
2629
+ # Do nothing.
2630
+ end
2631
+
2068
2632
  desc "Restart Application"
2069
2633
  task :restart, :roles =&gt; :app do
2070
- run "touch #{current_path}/tmp/restart.txt"
2634
+ run "touch #{current_release}/tmp/restart.txt"
2071
2635
  end
2072
2636
  end</tt></pre>
2073
2637
  </div></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">
2080
- <div class="para"><p>You may notice that for each deploy, a new spawner server is
2081
- created (it'll show up in <tt>passenger-memory-stats</tt>). Indeed, Capistrano will deploy
2082
- to a path ending with <em>/current</em> (ie : <em>/var/www/yourapp/current</em>), so that you don't
2638
+ <div class="paragraph"><p>You may notice that after each deploy, a new spawner server is
2639
+ created (it&#8217;ll show up in <tt>passenger-memory-stats</tt>). Indeed, Capistrano will deploy
2640
+ to a path ending with <em>/current</em> (ie : <em>/u/apps/yourapp/current</em>), so that you don&#8217;t
2083
2641
  have to care about revisions in your virtual host configuration. This <em>/current</em> directory
2084
2642
  is a symlink to the current revision deployed (<em>/path_to_app/releases/date_of_the_release</em>).
2085
- Therefore, when deploying a new version, the symlink will change, and Phusion Passenger
2086
- will think it's a new application, thereby creating a new spawner server:</p></div>
2643
+ Phusion Passenger recognizes applications by their full canonical path, so after
2644
+ deploying a new version, Phusion Passenger will think that the new version is
2645
+ a totally different application, thereby creating a new spawner server:</p></div>
2087
2646
  <div class="listingblock">
2088
2647
  <div class="content">
2089
- <pre><tt>1001 30291 [...] Passenger ApplicationSpawner: /var/www/my_app/releases/20080509104413
2090
- 1001 31371 [...] Passenger ApplicationSpawner: /var/www/my_app/releases/20080509104632</tt></pre>
2648
+ <pre><tt>1001 30291 [...] Passenger ApplicationSpawner: /u/apps/my_app/releases/20080509104413
2649
+ 1001 31371 [...] Passenger ApplicationSpawner: /u/apps/my_app/releases/20080509104632</tt></pre>
2091
2650
  </div></div>
2092
- <div class="para"><p>Don't worry about this. The (old) spawner server will terminate itself after its default
2093
- timeout (10 minutes), so you will not run out of memory.</p></div>
2094
- <div class="para"><p>If you really want to release the spawner server's memory immediately, then you can add a command
2651
+ <div class="paragraph"><p>Don&#8217;t worry about this. The (old) spawner server will terminate itself after its
2652
+ timeout period (10 minutes by default), so you will not run out of memory.</p></div>
2653
+ <div class="paragraph"><p>If you really want to release the spawner server&#8217;s memory immediately, then you can add a command
2095
2654
  to your Capistrano script to terminate the Passenger spawn server after each deploy. That
2096
2655
  command is as follows:</p></div>
2097
2656
  <div class="listingblock">
2098
2657
  <div class="content">
2099
2658
  <pre><tt>kill $( passenger-memory-stats | grep 'Passenger spawn server' | awk '{ print $1 }' )</tt></pre>
2100
2659
  </div></div>
2101
- <div class="para"><p>Killing the spawn server is completely safe, because Phusion Passenger will restart the
2660
+ <div class="paragraph"><p>Killing the spawn server is completely safe, because Phusion Passenger will restart the
2102
2661
  spawn server if it has been terminated.</p></div>
2103
- </td>
2104
- </tr></table>
2105
- </div>
2106
2662
  <h3 id="_moving_phusion_passenger_to_a_different_directory">8.4. Moving Phusion Passenger to a different directory</h3><div style="clear:left"></div>
2107
- <div class="para"><p>It is possible to relocate the Phusion Passenger files to a different directory. It
2663
+ <div class="paragraph"><p>It is possible to relocate the Phusion Passenger files to a different directory. It
2108
2664
  involves two steps:</p></div>
2109
- <div class="olist"><ol>
2665
+ <div class="olist arabic"><ol class="arabic">
2110
2666
  <li>
2111
2667
  <p>
2112
2668
  Moving the directory.
@@ -2118,9 +2674,9 @@ Updating the &#8220;PassengerRoot&#8221; configuration option in Apache.
2118
2674
  </p>
2119
2675
  </li>
2120
2676
  </ol></div>
2121
- <div class="para"><p>For example, if Phusion Passenger is located in <em>/opt/passenger/</em>, and you'd like to
2677
+ <div class="paragraph"><p>For example, if Phusion Passenger is located in <em>/opt/passenger/</em>, and you&#8217;d like to
2122
2678
  move it to <em>/usr/local/passenger/</em>, then do this:</p></div>
2123
- <div class="olist"><ol>
2679
+ <div class="olist arabic"><ol class="arabic">
2124
2680
  <li>
2125
2681
  <p>
2126
2682
  Run the following command:
@@ -2141,45 +2697,426 @@ Edit your Apache configuration file, and set:
2141
2697
  </li>
2142
2698
  </ol></div>
2143
2699
  <h3 id="_installing_multiple_ruby_on_rails_versions">8.5. Installing multiple Ruby on Rails versions</h3><div style="clear:left"></div>
2144
- <div class="para"><p>Each Ruby on Rails applications that are going to be deployed may require a
2700
+ <div class="paragraph"><p>Each Ruby on Rails applications that are going to be deployed may require a
2145
2701
  specific Ruby on Rails version. You can install a specific version with
2146
2702
  this command:</p></div>
2147
2703
  <div class="listingblock">
2148
2704
  <div class="content">
2149
2705
  <pre><tt>gem install rails -v X.X.X</tt></pre>
2150
2706
  </div></div>
2151
- <div class="para"><p>where <em>X.X.X</em> is the version number of Ruby on Rails.</p></div>
2152
- <div class="para"><p>All of these versions will exist in parallel, and will not conflict with each
2707
+ <div class="paragraph"><p>where <em>X.X.X</em> is the version number of Ruby on Rails.</p></div>
2708
+ <div class="paragraph"><p>All of these versions will exist in parallel, and will not conflict with each
2153
2709
  other. Phusion Passenger will automatically make use of the correct version.</p></div>
2154
2710
  <h3 id="_x_sendfile_support">8.6. X-Sendfile support</h3><div style="clear:left"></div>
2155
- <div class="para"><p>Phusion Passenger does not provide X-Sendfile support by itself. Please install
2711
+ <div class="paragraph"><p>Phusion Passenger does not provide X-Sendfile support by itself. Please install
2156
2712
  <a href="http://tn123.ath.cx/mod_xsendfile/">mod_xsendfile</a> for X-Sendfile support.</p></div>
2157
2713
  <h3 id="_upload_progress">8.7. Upload progress</h3><div style="clear:left"></div>
2158
- <div class="para"><p>Phusion Passenger does not provide upload progress support by itself. Please
2159
- try drogus's <a href="http://github.com/drogus/apache-upload-progress-module/tree/master">
2714
+ <div class="paragraph"><p>Phusion Passenger does not provide upload progress support by itself. Please
2715
+ try drogus&#8217;s <a href="http://github.com/drogus/apache-upload-progress-module/tree/master">
2160
2716
  Apache upload progress module</a> instead.</p></div>
2717
+ <h3 id="_making_the_application_restart_after_each_request">8.8. Making the application restart after each request</h3><div style="clear:left"></div>
2718
+ <div class="paragraph"><p>In some situations it might be desirable to restart the web application after
2719
+ each request, for example when developing a non-Rails application that doesn&#8217;t
2720
+ support code reloading, or when developing a web framework.</p></div>
2721
+ <div class="paragraph"><p>To achieve this, simply create the file <em>tmp/always_restart.txt</em> in your
2722
+ application&#8217;s root folder. Unlike <em>restart.txt</em>, Phusion Passenger does not
2723
+ check for this file&#8217;s timestamp: Phusion Passenger will always restart the
2724
+ application, as long as <em>always_restart.txt</em> exists.</p></div>
2725
+ <div class="admonitionblock">
2726
+ <table><tr>
2727
+ <td class="icon">
2728
+ <img src="./images/icons/note.png" alt="Note" />
2729
+ </td>
2730
+ <td class="content">If you&#8217;re just developing a Rails application then you probably don&#8217;t need
2731
+ this feature. If you set <em>RailsEnv development</em> in your Apache configuration,
2732
+ then Rails will automatically reload your application code after each request.
2733
+ <em>always_restart.txt</em> is only useful if you&#8217;re working on Ruby on Rails itself,
2734
+ or when you&#8217;re not developing a Rails application and your web framework
2735
+ does not support code reloading.</td>
2736
+ </tr></table>
2737
+ </div>
2161
2738
  </div>
2162
2739
  <h2 id="_appendix_a_about_this_document">9. Appendix A: About this document</h2>
2163
2740
  <div class="sectionbody">
2164
- <div class="para"><p>The text of this document is licensed under the
2741
+ <div class="paragraph"><p>The text of this document is licensed under the
2165
2742
  <a href="http://creativecommons.org/licenses/by-sa/3.0/">Creative Commons
2166
2743
  Attribution-Share Alike 3.0 Unported License</a>.</p></div>
2167
- <div class="para"><p><span class="image">
2744
+ <div class="paragraph"><p><span class="image">
2168
2745
  <a class="image" href="http://creativecommons.org/licenses/by-sa/3.0/">
2169
2746
  <img src="images/by_sa.png" alt="images/by_sa.png" />
2170
2747
  </a>
2171
2748
  </span></p></div>
2172
- <div class="para"><p>Phusion Passenger is brought to you by <a href="http://www.phusion.nl/">Phusion</a>.</p></div>
2173
- <div class="para"><p><span class="image">
2749
+ <div class="paragraph"><p>Phusion Passenger is brought to you by <a href="http://www.phusion.nl/">Phusion</a>.</p></div>
2750
+ <div class="paragraph"><p><span class="image">
2174
2751
  <a class="image" href="http://www.phusion.nl/">
2175
2752
  <img src="images/phusion_banner.png" alt="images/phusion_banner.png" />
2176
2753
  </a>
2177
2754
  </span></p></div>
2178
- <div class="para"><p>Phusion Passenger is a trademark of Hongli Lai &amp; Ninh Bui.</p></div>
2755
+ <div class="paragraph"><p>Phusion Passenger is a trademark of Hongli Lai &amp; Ninh Bui.</p></div>
2756
+ </div>
2757
+ <h2 id="_appendix_b_terminology">10. Appendix B: Terminology</h2>
2758
+ <div class="sectionbody">
2759
+ <h3 id="application_root">10.1. Application root</h3><div style="clear:left"></div>
2760
+ <div class="paragraph"><p>The root directory of an application that&#8217;s served by Phusion Passenger.</p></div>
2761
+ <div class="paragraph"><p>In case of Ruby on Rails applications, this is the directory that contains
2762
+ <em>Rakefile</em>, <em>app/</em>, <em>config/</em>, <em>public/</em>, etc. In other words, the directory
2763
+ pointed to by <tt>RAILS_ROOT</tt>. For example, take the following directory structure:</p></div>
2764
+ <div class="listingblock">
2765
+ <div class="content">
2766
+ <pre><tt>/apps/foo/ &lt;------ This is the Rails application's application root!
2767
+ |
2768
+ +- app/
2769
+ | |
2770
+ | +- controllers/
2771
+ | |
2772
+ | +- models/
2773
+ | |
2774
+ | +- views/
2775
+ |
2776
+ +- config/
2777
+ | |
2778
+ | +- environment.rb
2779
+ | |
2780
+ | +- ...
2781
+ |
2782
+ +- public/
2783
+ | |
2784
+ | +- ...
2785
+ |
2786
+ +- ...</tt></pre>
2787
+ </div></div>
2788
+ <div class="paragraph"><p>In case of Rack applications, this is the directory that contains <em>config.ru</em>.
2789
+ For example, take the following directory structure:</p></div>
2790
+ <div class="listingblock">
2791
+ <div class="content">
2792
+ <pre><tt>/apps/bar/ &lt;----- This is the Rack application's application root!
2793
+ |
2794
+ +- public/
2795
+ | |
2796
+ | +- ...
2797
+ |
2798
+ +- config.ru
2799
+ |
2800
+ +- ...</tt></pre>
2801
+ </div></div>
2802
+ <div class="paragraph"><p>In case of Python (WSGI) applications, this is the directory that contains
2803
+ <em>passenger_wsgi.py</em>. For example, take the following directory structure:</p></div>
2804
+ <div class="listingblock">
2805
+ <div class="content">
2806
+ <pre><tt>/apps/baz/ &lt;----- This is the WSGI application's application root!
2807
+ |
2808
+ +- public/
2809
+ | |
2810
+ | +- ...
2811
+ |
2812
+ +- passenger_wsgi.py
2813
+ |
2814
+ +- ...</tt></pre>
2815
+ </div></div>
2816
+ </div>
2817
+ <h2 id="spawning_methods_explained">11. Appendix C: Spawning methods explained</h2>
2818
+ <div class="sectionbody">
2819
+ <div class="paragraph"><p>At its core, Phusion Passenger is an HTTP proxy and process manager. It spawns
2820
+ Ruby on Rails/Rack/WSGI worker processes (which may also be referred to as
2821
+ <em>backend processes</em>), and forwards incoming HTTP request to one of the worker
2822
+ processes.</p></div>
2823
+ <div class="paragraph"><p>While this may sound simple, there&#8217;s not just one way to spawn worker processes.
2824
+ Let&#8217;s go over the different spawning methods. For simplicity&#8217;s sake, let&#8217;s
2825
+ assume that we&#8217;re only talking about Ruby on Rails applications.</p></div>
2826
+ <h3 id="_the_most_straightforward_and_traditional_way_conservative_spawning">11.1. The most straightforward and traditional way: conservative spawning</h3><div style="clear:left"></div>
2827
+ <div class="paragraph"><p>Phusion Passenger could create a new Ruby process, which will then load the
2828
+ Rails application along with the entire Rails framework. This process will then
2829
+ enter an request handling main loop.</p></div>
2830
+ <div class="paragraph"><p>This is the most straightforward way to spawn worker processes. If you&#8217;re
2831
+ familiar with the Mongrel application server, then this approach is exactly
2832
+ what mongrel_cluster performs: it creates N worker processes, each which loads
2833
+ a full copy of the Rails application and the Rails framework in memory. The Thin
2834
+ application server employs pretty much the same approach.</p></div>
2835
+ <div class="paragraph"><p>Note that Phusion Passenger&#8217;s version of conservative spawning differs slightly
2836
+ from mongrel_cluster. Mongrel_cluster creates entirely new Ruby processes. In
2837
+ programmers jargon, mongrel_cluster creates new Ruby processes by forking the
2838
+ current process and exec()-ing a new Ruby interpreter. Phusion Passenger on the
2839
+ other hand creates processes that reuse the already loaded Ruby interpreter. In
2840
+ programmers jargon, Phusion Passenger calls fork(), but not exec().</p></div>
2841
+ <h3 id="_the_smart_spawning_method">11.2. The smart spawning method</h3><div style="clear:left"></div>
2842
+ <div class="admonitionblock">
2843
+ <table><tr>
2844
+ <td class="icon">
2845
+ <img src="./images/icons/note.png" alt="Note" />
2846
+ </td>
2847
+ <td class="content">Smart spawning is only available for Ruby on Rails applications, not for
2848
+ Rack applications or WSGI applications.</td>
2849
+ </tr></table>
2850
+ </div>
2851
+ <div class="paragraph"><p>While conservative spawning works well, it&#8217;s not as efficient as it could be
2852
+ because each worker process has its own private copy of the Rails application
2853
+ as well as the Rails framework. This wastes memory as well as startup time.</p></div>
2854
+ <div class="paragraph"><p><span class="image">
2855
+ <img src="images/conservative_spawning.png" alt="Worker processes and conservative spawning" title="Worker processes and conservative spawning" />
2856
+ </span><br />
2857
+ <em>Figure: Worker processes and conservative spawning. Each worker process has its
2858
+ own private copy of the application code and Rails framework code.</em></p></div>
2859
+ <div class="paragraph"><p>It is possible to make the different worker processes share the memory occupied
2860
+ by application and Rails framework code, by utilizing so-called
2861
+ copy-on-write semantics of the virtual memory system on modern operating
2862
+ systems. As a side effect, the startup time is also reduced. This is technique
2863
+ is exploited by Phusion Passenger&#8217;s <em>smart</em> and <em>smart-lv2</em> spawn methods.</p></div>
2864
+ <h4 id="_how_it_works">11.2.1. How it works</h4>
2865
+ <div class="paragraph"><p>When the <em>smart-lv2</em> spawn method is being used, Phusion Passenger will first
2866
+ create a so-called <em>ApplicationSpawner server</em> process. This process loads the
2867
+ entire Rails application along with the Rails framework, by loading
2868
+ <em>environment.rb</em>. Then, whenever Phusion Passenger needs a new worker process,
2869
+ it will instruct the ApplicationSpawner server to do so. The ApplicationSpawner
2870
+ server will create a worker new process
2871
+ that reuses the already loaded Rails application/framework. Creating a worker
2872
+ process through an already running ApplicationSpawner server is very fast, about
2873
+ 10 times faster than loading the Rails application/framework from scratch. If
2874
+ the Ruby interpreter is copy-on-write friendly (that is, if you&#8217;re running
2875
+ <a href="#reducing_memory_usage">Ruby Enterprise Edition</a>) then all created worker
2876
+ processes will share as much common
2877
+ memory as possible. That is, they will all share the same application and Rails
2878
+ framework code.</p></div>
2879
+ <div class="paragraph"><p><span class="image">
2880
+ <img src="images/smart-lv2.png" alt="images/smart-lv2.png" />
2881
+ </span><br />
2882
+ <em>Figure: Worker processes and the smart-lv2 spawn method. All worker processes,
2883
+ as well as the ApplicationSpawner, share the same application code and Rails
2884
+ framework code.</em></p></div>
2885
+ <div class="paragraph"><p>The <em>smart</em> spawn method goes even further, by caching the Rails framework in
2886
+ another process called the <em>FrameworkSpawner server</em>. This process only loads
2887
+ the Rails framework, not the application. When a FrameworkSpawner server is
2888
+ instructed to create a new worker process, it will create a new
2889
+ ApplicationSpawner to which the instruction will be delegated. All those
2890
+ ApplicationSpawner servers, as well as all worker processes created by those
2891
+ ApplicationSpawner servers, will share the same Rails framework code.</p></div>
2892
+ <div class="paragraph"><p>The <em>smart-lv2</em> method allows different worker processes that belong to the same
2893
+ application to share memory. The <em>smart</em> method allows different worker
2894
+ processes - that happen to use the same Rails version - to share memory, even if
2895
+ they don&#8217;t belong to the same application.</p></div>
2896
+ <div class="paragraph"><p>Notes:</p></div>
2897
+ <div class="ulist"><ul>
2898
+ <li>
2899
+ <p>
2900
+ Vendored Rails frameworks cannot be shared by different applications, even if
2901
+ both vendored Rails frameworks are the same version. So for efficiency reasons
2902
+ we don&#8217;t recommend vendoring Rails.
2903
+ </p>
2904
+ </li>
2905
+ <li>
2906
+ <p>
2907
+ ApplicationSpawner and FrameworkSpawner servers have an idle timeout just
2908
+ like worker processes. If an ApplicationSpawner/FrameworkSpawner server hasn&#8217;t
2909
+ been instructed to do anything for a while, it will be shutdown in order to
2910
+ conserve memory. This idle timeout is configurable.
2911
+ </p>
2912
+ </li>
2913
+ </ul></div>
2914
+ <h4 id="_summary_of_benefits">11.2.2. Summary of benefits</h4>
2915
+ <div class="paragraph"><p>Suppose that Phusion Passenger needs a new worker process for an application
2916
+ that uses Rails 2.2.1.</p></div>
2917
+ <div class="ulist"><ul>
2918
+ <li>
2919
+ <p>
2920
+ If the <em>smart-lv2</em> spawning method is used, and an ApplicationSpawner server
2921
+ for this application is already running, then worker process creation time is
2922
+ about 10 times faster than conservative spawning. This worker process will also
2923
+ share application and Rails framework code memory with the ApplicationSpawner
2924
+ server and the worker processes that had been spawned by this ApplicationSpawner
2925
+ server.
2926
+ </p>
2927
+ </li>
2928
+ <li>
2929
+ <p>
2930
+ If the <em>smart</em> spawning method is used, and a FrameworkSpawner server for
2931
+ Rails 2.2.1 is already running, but no ApplicationSpawner server for this
2932
+ application is running, then worker process creation time is about 2 times
2933
+ faster than conservative spawning. If there is an ApplicationSpawner server
2934
+ for this application running, then worker process creation time is about 10
2935
+ times faster. This worker process will also share application and Rails
2936
+ framework code memory with the ApplicationSpawner and FrameworkSpawner
2937
+ servers.
2938
+ </p>
2939
+ </li>
2940
+ </ul></div>
2941
+ <div class="paragraph"><p>You could compare ApplicationSpawner and FrameworkSpawner servers with stem
2942
+ cells, that have the ability to quickly change into more specific cells (worker
2943
+ process).</p></div>
2944
+ <div class="paragraph"><p>In practice, the smart spawning methods could mean a memory saving of about 33%,
2945
+ assuming that your Ruby interpreter is <a href="#reducing_memory_usage">copy-on-write friendly</a>.</p></div>
2946
+ <div class="paragraph"><p>Of course, smart spawning is not without gotchas. But if you understand the
2947
+ gotchas you can easily reap the benefits of smart spawning.</p></div>
2948
+ <h3 id="_smart_spawning_gotcha_1_unintential_file_descriptor_sharing">11.3. Smart spawning gotcha #1: unintential file descriptor sharing</h3><div style="clear:left"></div>
2949
+ <div class="paragraph"><p>Because worker processes are created by forking from an ApplicationSpawner
2950
+ server, it will share all file descriptors that are opened by the
2951
+ ApplicationSpawner server. (This is part of the semantics of the Unix
2952
+ <em>fork()</em> system call. You might want to Google it if you&#8217;re not familiar with
2953
+ it.) A file descriptor is a handle which can be an opened file, an opened socket
2954
+ connection, a pipe, etc. If different worker processes write to such a file
2955
+ descriptor at the same time, then their write calls will be interleaved, which
2956
+ may potentially cause problems.</p></div>
2957
+ <div class="paragraph"><p>The problem commonly involves socket connections that are unintentially being
2958
+ shared. You can fix it by closing and reestablishing the connection when Phusion
2959
+ Passenger is creating a new worker process. Phusion Passenger provides the API
2960
+ call <tt>PhusionPassenger.on_event(:starting_worker_process)</tt> to do so. So you
2961
+ could insert the following code in your <em>environment.rb</em>:</p></div>
2962
+ <div class="listingblock">
2963
+ <div class="content"><!-- Generator: GNU source-highlight 2.4
2964
+ by Lorenzo Bettini
2965
+ http://www.lorenzobettini.it
2966
+ http://www.gnu.org/software/src-highlite -->
2967
+ <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>
2968
+ PhusionPassenger<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">on_event</span></span><span style="color: #990000">(:</span>starting_worker_process<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">do</span></span> <span style="color: #990000">|</span>forked<span style="color: #990000">|</span>
2969
+ <span style="font-weight: bold"><span style="color: #0000FF">if</span></span> forked
2970
+ <span style="font-style: italic"><span style="color: #9A1900"># We're in smart spawning mode.</span></span>
2971
+ <span style="color: #990000">...</span> code to reestablish socket connections here <span style="color: #990000">...</span>
2972
+ <span style="font-weight: bold"><span style="color: #0000FF">else</span></span>
2973
+ <span style="font-style: italic"><span style="color: #9A1900"># We're in conservative spawning mode. We don't need to do anything.</span></span>
2974
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
2975
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
2976
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
2977
+ <div class="paragraph"><p>Note that Phusion Passenger automatically reestablishes the connection to the
2978
+ database upon creating a new worker process, which is why you normally do not
2979
+ encounter any database issues when using smart spawning mode.</p></div>
2980
+ <h4 id="_example_1_memcached_connection_sharing_harmful">11.3.1. Example 1: Memcached connection sharing (harmful)</h4>
2981
+ <div class="paragraph"><p>Suppose we have a Rails application that connects to a Memcached server in
2982
+ <em>environment.rb</em>. This causes the ApplicationSpawner to have a socket connection
2983
+ (file descriptor) to the Memcached server, as shown in the following figure:</p></div>
2984
+ <div class="literalblock">
2985
+ <div class="content">
2986
+ <pre><tt>+--------------------+
2987
+ | ApplicationSpawner |-----------[Memcached server]
2988
+ +--------------------+</tt></pre>
2989
+ </div></div>
2990
+ <div class="paragraph"><p>Phusion Passenger then proceeds with creating a new Rails worker process, which
2991
+ is to process incoming HTTP requests. The result will look like this:</p></div>
2992
+ <div class="literalblock">
2993
+ <div class="content">
2994
+ <pre><tt>+--------------------+
2995
+ | ApplicationSpawner |------+----[Memcached server]
2996
+ +--------------------+ |
2997
+ |
2998
+ +--------------------+ |
2999
+ | Worker process 1 |-----/
3000
+ +--------------------+</tt></pre>
3001
+ </div></div>
3002
+ <div class="paragraph"><p>Since a <em>fork()</em> makes a (virtual) complete copy of a process, all its file
3003
+ descriptors will be copied as well. What we see here is that ApplicationSpawner
3004
+ and Worker process 1 both share the same connection to Memcached.</p></div>
3005
+ <div class="paragraph"><p>Now supposed that your site gets Slashdotted and Phusion Passenger needs to
3006
+ spawn another worker process. It does so by forking ApplicationSpawner. The
3007
+ result is now as follows:</p></div>
3008
+ <div class="literalblock">
3009
+ <div class="content">
3010
+ <pre><tt>+--------------------+
3011
+ | ApplicationSpawner |------+----[Memcached server]
3012
+ +--------------------+ |
3013
+ |
3014
+ +--------------------+ |
3015
+ | Worker process 1 |-----/|
3016
+ +--------------------+ |
3017
+ |
3018
+ +--------------------+ |
3019
+ | Worker process 2 |-----/
3020
+ +--------------------+</tt></pre>
3021
+ </div></div>
3022
+ <div class="paragraph"><p>As you can see, Worker process 1 and Worker process 2 have the same Memcache
3023
+ connection.</p></div>
3024
+ <div class="paragraph"><p>Suppose that users Joe and Jane visit your website at the same time. Joe&#8217;s
3025
+ request is handled by Worker process 1, and Jane&#8217;s request is handled by Worker
3026
+ process 2. Both worker processes want to fetch something from Memcached. Suppose
3027
+ that in order to do that, both handlers need to send a "FETCH" command to Memcached.</p></div>
3028
+ <div class="paragraph"><p>But suppose that, after worker process 1 having only sent "FE", a context switch
3029
+ occurs, and worker process 2 starts sending a "FETCH" command to Memcached as
3030
+ well. If worker process 2 succeeds in sending only one bye, <em>F</em>, then Memcached
3031
+ will receive a command which begins with "FEF", a command that it does not
3032
+ recognize. In other words: the data from both handlers get interleaved. And thus
3033
+ Memcached is forced to handle this as an error.</p></div>
3034
+ <div class="paragraph"><p>This problem can be solved by reestablishing the connection to Memcached after forking:</p></div>
3035
+ <div class="literalblock">
3036
+ <div class="content">
3037
+ <pre><tt>+--------------------+
3038
+ | ApplicationSpawner |------+----[Memcached server]
3039
+ +--------------------+ | |
3040
+ | |
3041
+ +--------------------+ | |
3042
+ | Worker process 1 |-----/| |
3043
+ +--------------------+ | | &lt;--- created this
3044
+ X | new
3045
+ | connection
3046
+ X &lt;-- closed this |
3047
+ +--------------------+ | old |
3048
+ | Worker process 2 |-----/ connection |
3049
+ +--------------------+ |
3050
+ | |
3051
+ +-------------------------------------+</tt></pre>
3052
+ </div></div>
3053
+ <div class="paragraph"><p>Worker process 2 now has its own, separate communication channel with Memcached.
3054
+ The code in <em>environment.rb</em> looks like this:</p></div>
3055
+ <div class="listingblock">
3056
+ <div class="content"><!-- Generator: GNU source-highlight 2.4
3057
+ by Lorenzo Bettini
3058
+ http://www.lorenzobettini.it
3059
+ http://www.gnu.org/software/src-highlite -->
3060
+ <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>
3061
+ PhusionPassenger<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">on_event</span></span><span style="color: #990000">(:</span>starting_worker_process<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">do</span></span> <span style="color: #990000">|</span>forked<span style="color: #990000">|</span>
3062
+ <span style="font-weight: bold"><span style="color: #0000FF">if</span></span> forked
3063
+ <span style="font-style: italic"><span style="color: #9A1900"># We're in smart spawning mode.</span></span>
3064
+ reestablish_connection_to_memcached
3065
+ <span style="font-weight: bold"><span style="color: #0000FF">else</span></span>
3066
+ <span style="font-style: italic"><span style="color: #9A1900"># We're in conservative spawning mode. We don't need to do anything.</span></span>
3067
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
3068
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
3069
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
3070
+ <h4 id="_example_2_log_file_sharing_not_harmful">11.3.2. Example 2: Log file sharing (not harmful)</h4>
3071
+ <div class="paragraph"><p>There are also cases in which unintential file descriptor sharing is not harmful.
3072
+ One such case is log file file descriptor sharing. Even if two processes write
3073
+ to the log file at the same time, the worst thing that can happen is that the
3074
+ data in the log file is interleaved.</p></div>
3075
+ <div class="paragraph"><p>To guarantee that the data written to the log file is never interleaved, you
3076
+ must synchronize write access via an inter-process synchronization mechanism,
3077
+ such as file locks. Reopening the log file, like you would have done in the
3078
+ Memcached example, doesn&#8217;t help.</p></div>
3079
+ <h3 id="_smart_spawning_gotcha_2_the_need_to_revive_threads">11.4. Smart spawning gotcha #2: the need to revive threads</h3><div style="clear:left"></div>
3080
+ <div class="paragraph"><p>Another part of the <em>fork()</em> system call&#8217;s semantics is the fact that threads
3081
+ disappear after a fork call. So if you&#8217;ve created any threads in environment.rb,
3082
+ then those threads will no longer be running in newly created worker process.
3083
+ You need to revive them when a new worker process is created. Use the
3084
+ <tt>:starting_worker_process</tt> event that Phusion Passenger provides, like this:</p></div>
3085
+ <div class="listingblock">
3086
+ <div class="content"><!-- Generator: GNU source-highlight 2.4
3087
+ by Lorenzo Bettini
3088
+ http://www.lorenzobettini.it
3089
+ http://www.gnu.org/software/src-highlite -->
3090
+ <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>
3091
+ PhusionPassenger<span style="color: #990000">.</span><span style="font-weight: bold"><span style="color: #000000">on_event</span></span><span style="color: #990000">(:</span>starting_worker_process<span style="color: #990000">)</span> <span style="font-weight: bold"><span style="color: #0000FF">do</span></span> <span style="color: #990000">|</span>forked<span style="color: #990000">|</span>
3092
+ <span style="font-weight: bold"><span style="color: #0000FF">if</span></span> forked
3093
+ <span style="font-style: italic"><span style="color: #9A1900"># We're in smart spawning mode.</span></span>
3094
+ <span style="color: #990000">...</span> code to revive threads here <span style="color: #990000">...</span>
3095
+ <span style="font-weight: bold"><span style="color: #0000FF">else</span></span>
3096
+ <span style="font-style: italic"><span style="color: #9A1900"># We're in conservative spawning mode. We don't need to do anything.</span></span>
3097
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
3098
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
3099
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span></tt></pre></div></div>
3100
+ <h3 id="_smart_spawning_gotcha_3_code_load_order">11.5. Smart spawning gotcha #3: code load order</h3><div style="clear:left"></div>
3101
+ <div class="paragraph"><p>This gotcha is only applicable to the <em>smart</em> spawn method, not the <em>smart-lv2</em>
3102
+ spawn method.</p></div>
3103
+ <div class="paragraph"><p>If your application expects the Rails framework to be not loaded during the
3104
+ beginning of <em>environment.rb</em>, then it can cause problems when an
3105
+ ApplicationSpawner is created from a FrameworkSpawner, which already has the
3106
+ Rails framework loaded. The most common case is when applications try to patch
3107
+ Rails by dropping a modified file that has the same name as Rails&#8217;s own file,
3108
+ in a path that comes earlier in the Ruby search path.</p></div>
3109
+ <div class="paragraph"><p>For example, suppose that we have an application which has a patched version
3110
+ of <em>active_record/base.rb</em> located in <em>RAILS_ROOT/lib/patches</em>, and
3111
+ <em>RAILS_ROOT/lib/patches</em> comes first in the Ruby load path. When conservative
3112
+ spawning is used, the patched version of <em>base.rb</em> is properly loaded. When
3113
+ <em>smart</em> (not <em>smart-lv2</em>) spawning is used, the original <em>base.rb</em> is used
3114
+ because it was already loaded, so a subsequent <tt>require "active_record/base"</tt>
3115
+ has no effect.</p></div>
2179
3116
  </div>
2180
3117
  <div id="footer">
2181
3118
  <div id="footer-text">
2182
- Last updated 2008-12-15 15:26:50 CEST
3119
+ Last updated 2009-03-13 17:14:24 CEST
2183
3120
  </div>
2184
3121
  </div>
2185
3122
  </body>