ServerRoot "<%= @server_root %>"
Listen 127.0.0.1:<%= @port %>

<% if @www_user %>
	User <%= @www_user %>
<% end %>
<% if @www_group %>
	Group <%= @www_group %>
<% end %>

<% if !has_builtin_module?('mod_log_config.c') %>
	LoadModule log_config_module "<%= modules_dir %>/mod_log_config.so"
<% end %>
<% if !has_builtin_module?('mod_mime.c') %>
	LoadModule mime_module "<%= modules_dir %>/mod_mime.so"
<% end %>
<% if !has_builtin_module?('mod_autoindex.c') %>
	LoadModule autoindex_module "<%= modules_dir %>/mod_autoindex.so"
<% end %>
<% if !has_builtin_module?('mod_dir.c') %>
	LoadModule dir_module "<%= modules_dir %>/mod_dir.so"
<% end %>
<% if !has_builtin_module?('mod_alias.c') %>
	LoadModule alias_module "<%= modules_dir %>/mod_alias.so"
<% end %>
<% if !has_builtin_module?('mod_rewrite.c') %>
	LoadModule rewrite_module "<%= modules_dir %>/mod_rewrite.so"
<% end %>
<% if !has_builtin_module?('mod_env.c') %>
	LoadModule env_module "<%= modules_dir %>/mod_env.so"
<% end %>
<% if PlatformInfo.httpd_version >= '2.4.0' %>
	LoadModule authz_core_module "<%= modules_dir %>/mod_authz_core.so"
	<% if !has_builtin_module?('mod_unixd.c') %>
		LoadModule unixd_module "<%= modules_dir %>/mod_unixd.so"
	<% end %>
<% end %>

<% if !has_builtin_module?('prefork.c') &&
      !has_builtin_module?('worker.c') &&
      !has_builtin_module?('event.c') %>  
	<% if has_module?('mod_mpm_event.so') %>
		LoadModule mpm_event_module "<%= modules_dir %>/mod_mpm_event.so"
	<% elsif has_module?('mod_mpm_worker.so') %>
		LoadModule mpm_worker_module "<%= modules_dir %>/mod_mpm_worker.so"
	<% elsif has_module?('mod_mpm_prefork.so') %>
		LoadModule mpm_prefork_module "<%= modules_dir %>/mod_mpm_event.so"
	<% else %>
		<% raise "Could not find any mpm module in: #{Dir.entries(modules_dir).inspect}" %>
	<% end %>
<% end %>

LoadModule passenger_module "<%= @mod_passenger %>"

PassengerRoot "<%= @passenger_root %>"
PassengerDefaultRuby "<%= PlatformInfo.ruby_command %>"
PassengerDefaultUser <%= CONFIG['default_user'] %>
PassengerDefaultGroup <%= CONFIG['default_group'] %>
PassengerTempDir "<%= @passenger_temp_dir %>"
RailsEnv production
RackEnv production
PassengerLogLevel 1
<% for line in @extra %>
	<%= line %>
<% end %>

TypesConfig "<%= @server_root %>/mime.types"
StartServers          1
ServerLimit          10
MaxRequestsPerChild  50
MaxClients           10
<IfModule mpm_prefork_module>
	MinSpareServers       1
	MaxSpareServers       1
</IfModule>
<IfModule mpm_worker_module>
	MinSpareThreads       1
	MaxSpareThreads       1
	ThreadsPerChild       2
</IfModule>
<IfModule mpm_event_module>
	MinSpareThreads       1
	MaxSpareThreads       1
	ThreadsPerChild       2
</IfModule>

<Directory />
	AllowOverride all
</Directory>

ServerAdmin admin@passenger.test
ServerName passenger.test
DocumentRoot "<%= @server_root %>"

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

<% if !vhosts.empty? && PlatformInfo.httpd_version < '2.4.0' %>
	NameVirtualHost *:<%= @port %>
<% end %>
<% for vhost in vhosts %>
	<VirtualHost *:<%= @port %>>
		ServerName <%= vhost.domain %>
		DocumentRoot "<%= vhost.document_root %>"
		AllowEncodedSlashes On
		<% for line in vhost.additional_configs %>
			<%= line %>
		<% end %>
	</VirtualHost>
<% end %>
