Skip to content

Commit

Permalink
Support Apache 2.4 and the event MPM.
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed Apr 12, 2012
1 parent 7b45e32 commit 1a7a15a
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 15 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,7 @@
Release 3.0.12 Release 3.0.12
-------------- --------------


* [Apache] Support Apache 2.4. The event MPM is now also supported.
* [Nginx] Preferred Nginx version upgraded to 1.0.14. * [Nginx] Preferred Nginx version upgraded to 1.0.14.
* [Nginx] Preferred PCRE version upgraded to 8.30. * [Nginx] Preferred PCRE version upgraded to 8.30.
* [Nginx] Fixed compatibility with Nginx < 1.0.10. * [Nginx] Fixed compatibility with Nginx < 1.0.10.
Expand Down
4 changes: 2 additions & 2 deletions bin/passenger-install-apache2-module
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby #!/usr/bin/env ruby
# Phusion Passenger - http://www.modrails.com/ # Phusion Passenger - http://www.modrails.com/
# Copyright (c) 2010 Phusion # Copyright (c) 2010, 2011, 2012 Phusion
# #
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui. # "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
# #
Expand Down Expand Up @@ -124,7 +124,7 @@ private
mpm = nil mpm = nil
end end
end end
if mpm != "prefork" && mpm != "worker" if mpm != "prefork" && mpm != "worker" && mpm != "event"
new_screen new_screen
render_template 'apache2/apache_must_be_compiled_with_compatible_mpm', render_template 'apache2/apache_must_be_compiled_with_compatible_mpm',
:current_mpm => mpm :current_mpm => mpm
Expand Down
26 changes: 22 additions & 4 deletions ext/apache2/Hooks.cpp
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
/* /*
* Phusion Passenger - http://www.modrails.com/ * Phusion Passenger - http://www.modrails.com/
* Copyright (c) 2010 Phusion * Copyright (c) 2010, 2011, 2012 Phusion
* *
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui. * "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
* *
Expand Down Expand Up @@ -79,6 +79,10 @@ using namespace Passenger;


extern "C" module AP_MODULE_DECLARE_DATA passenger_module; extern "C" module AP_MODULE_DECLARE_DATA passenger_module;


#ifdef APLOG_USE_MODULE
APLOG_USE_MODULE(passenger);
#endif



/** /**
* If the HTTP client sends POST data larger than this value (in bytes), * If the HTTP client sends POST data larger than this value (in bytes),
Expand All @@ -99,6 +103,11 @@ extern "C" module AP_MODULE_DECLARE_DATA passenger_module;
#endif #endif
#endif #endif


#if HTTP_VERSION(AP_SERVER_MAJORVERSION_NUMBER, AP_SERVER_MINORVERSION_NUMBER) >= 2004
// Apache >= 2.4
#define unixd_config ap_unixd_config
#endif



/** /**
* Apache hook functions, wrapped in a class. * Apache hook functions, wrapped in a class.
Expand Down Expand Up @@ -980,14 +989,23 @@ class Hooks {




// Set standard CGI variables. // Set standard CGI variables.
addHeader(headers, "SERVER_SOFTWARE", ap_get_server_version()); #ifdef AP_GET_SERVER_VERSION_DEPRECATED
addHeader(headers, "SERVER_SOFTWARE", ap_get_server_description());
#else
addHeader(headers, "SERVER_SOFTWARE", ap_get_server_version());
#endif
addHeader(headers, "SERVER_PROTOCOL", r->protocol); addHeader(headers, "SERVER_PROTOCOL", r->protocol);
addHeader(headers, "SERVER_NAME", ap_get_server_name(r)); addHeader(headers, "SERVER_NAME", ap_get_server_name(r));
addHeader(headers, "SERVER_ADMIN", r->server->server_admin); addHeader(headers, "SERVER_ADMIN", r->server->server_admin);
addHeader(headers, "SERVER_ADDR", r->connection->local_ip); addHeader(headers, "SERVER_ADDR", r->connection->local_ip);
addHeader(headers, "SERVER_PORT", apr_psprintf(r->pool, "%u", ap_get_server_port(r))); addHeader(headers, "SERVER_PORT", apr_psprintf(r->pool, "%u", ap_get_server_port(r)));
addHeader(headers, "REMOTE_ADDR", r->connection->remote_ip); #if HTTP_VERSION(AP_SERVER_MAJORVERSION_NUMBER, AP_SERVER_MINORVERSION_NUMBER) >= 2004
addHeader(headers, "REMOTE_PORT", apr_psprintf(r->pool, "%d", r->connection->remote_addr->port)); addHeader(headers, "REMOTE_ADDR", r->connection->client_ip);
addHeader(headers, "REMOTE_PORT", apr_psprintf(r->pool, "%d", r->connection->client_addr->port));
#else
addHeader(headers, "REMOTE_ADDR", r->connection->remote_ip);
addHeader(headers, "REMOTE_PORT", apr_psprintf(r->pool, "%d", r->connection->remote_addr->port));
#endif
addHeader(headers, "REMOTE_USER", r->user); addHeader(headers, "REMOTE_USER", r->user);
addHeader(headers, "REQUEST_METHOD", r->method); addHeader(headers, "REQUEST_METHOD", r->method);
addHeader(headers, "QUERY_STRING", r->args ? r->args : ""); addHeader(headers, "QUERY_STRING", r->args ? r->args : "");
Expand Down
2 changes: 1 addition & 1 deletion ext/apache2/mod_passenger.c
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
/* /*
* Phusion Passenger - http://www.modrails.com/ * Phusion Passenger - http://www.modrails.com/
* Copyright (c) 2010 Phusion * Copyright (c) 2010, 2011, 2012 Phusion
* *
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui. * "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
* *
Expand Down
13 changes: 12 additions & 1 deletion lib/phusion_passenger/platform_info/apache.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
# Phusion Passenger - http://www.modrails.com/ # Phusion Passenger - http://www.modrails.com/
# Copyright (c) 2010 Phusion # Copyright (c) 2010, 2011, 2012 Phusion
# #
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui. # "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
# #
Expand Down Expand Up @@ -80,6 +80,17 @@ def self.httpd
end end
end end
memoize :httpd memoize :httpd

# The Apache version, or nil if Apache is not found.
def self.httpd_version
if httpd
`#{httpd} -v` =~ %r{Apache/([\d\.]+)}
return $1
else
return nil
end
end
memoize :httpd_version


# The absolute path to the 'apr-config' or 'apr-1-config' executable, # The absolute path to the 'apr-config' or 'apr-1-config' executable,
# or nil if not found. # or nil if not found.
Expand Down
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,9 @@
<red>WARNING:</red> <yellow>Apache doesn't seem to be compiled with the 'prefork' or 'worker' MPM</yellow> <red>WARNING:</red> <yellow>Apache doesn't seem to be compiled with the 'prefork', 'worker' or 'event' MPM</yellow>


Passenger has only been tested on Apache with the 'prefork' and the 'worker' Phusion Passenger has only been tested on Apache with the 'prefork', the
MPM. Your Apache installation is compiled with the '<%= @current_mpm %>' MPM. We recommend 'worker' and the 'worker' MPM. Your Apache installation is compiled with

This comment has been minimized.

Copy link
@joeglenn

joeglenn Apr 16, 2012

'worker' and the 'event' MPM

This comment has been minimized.

Copy link
@FooBarWidget

FooBarWidget Apr 16, 2012

Author Member

Doh. Fixed.

you to abort this installer and to recompile Apache with either the 'prefork' the '<%= @current_mpm %>' MPM. We recommend you to abort this installer and to recompile
or the 'worker' MPM. Apache with either the 'prefork', the 'worker' or the 'event' MPM.


<b>Press Ctrl-C to abort this installer (recommended).</b> <b>Press Ctrl-C to abort this installer (recommended).</b>
<b>Press Enter if you want to continue with installation anyway.</b> <b>Press Enter if you want to continue with installation anyway.</b>
15 changes: 13 additions & 2 deletions test/stub/apache2/httpd.conf.erb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ Listen 127.0.0.1:<%= @port %>
<% if !has_builtin_module?('mod_env.c') %> <% if !has_builtin_module?('mod_env.c') %>
LoadModule env_module "<%= modules_dir %>/mod_env.so" LoadModule env_module "<%= modules_dir %>/mod_env.so"
<% end %> <% end %>
<% if PlatformInfo.httpd_version >= '2.4.0' %>
LoadModule authz_core_module "<%= modules_dir %>/mod_authz_core.so"
LoadModule unixd_module "<%= modules_dir %>/mod_unixd.so"
<% end %>
LoadModule passenger_module "<%= @mod_passenger %>" LoadModule passenger_module "<%= @mod_passenger %>"


PassengerRoot "<%= @passenger_root %>" PassengerRoot "<%= @passenger_root %>"
Expand Down Expand Up @@ -57,6 +61,11 @@ MaxClients 10
MaxSpareThreads 1 MaxSpareThreads 1
ThreadsPerChild 2 ThreadsPerChild 2
</IfModule> </IfModule>
<IfModule mpm_event_module>
MinSpareThreads 1
MaxSpareThreads 1
ThreadsPerChild 2
</IfModule>


<Directory /> <Directory />
AllowOverride all AllowOverride all
Expand All @@ -66,12 +75,14 @@ ServerAdmin admin@passenger.test
ServerName passenger.test ServerName passenger.test
DocumentRoot "<%= @server_root %>" DocumentRoot "<%= @server_root %>"


LockFile <%= @server_root %>/httpd.lock <% if PlatformInfo.httpd_version < '2.4.0' %>
LockFile <%= @server_root %>/httpd.lock
<% end %>
PidFile <%= @server_root %>/httpd.pid PidFile <%= @server_root %>/httpd.pid
ErrorLog <%= @passenger_root %>/test/test.log ErrorLog <%= @passenger_root %>/test/test.log
CustomLog <%= @server_root %>/access.log combined CustomLog <%= @server_root %>/access.log combined


<% if !vhosts.empty? %> <% if !vhosts.empty? && PlatformInfo.httpd_version < '2.4.0' %>
NameVirtualHost *:<%= @port %> NameVirtualHost *:<%= @port %>
<% end %> <% end %>
<% for vhost in vhosts %> <% for vhost in vhosts %>
Expand Down

0 comments on commit 1a7a15a

Please sign in to comment.