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