Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a standard installation of Apache 2.4.6 (Amazon) with PHP 5.4.21 using the following configuration for my virtual host:

DirectoryIndex index.php
# ...
FallbackResource /index.php

My index.php is the epitome of simple:

<?php echo "Hello world";

Accessing http://<server-name>/ mysteriously shows the full page only after five seconds! Any other page has the expected response time (which is fast).

Those five seconds, as I came to find out, are related to the default waiting time of the Keep-Alive feature; in this case, the last few bytes of the chunked response are not sent until Apache severs the connection after that waiting time. Btw, that also completely ruins any gains that a persistent connection would otherwise give you.

Is this a known bug of Apache or am I missing something extremely obvious here?

share|improve this question
up vote 6 down vote accepted

From this bug report I realised that this problem could be related to the DirectoryIndex directive.

The standard Apache installation comes with the following section in the configuration:

<IfModule dir_module>
DirectoryIndex index.html

Any directives following this statement, such as the one in your virtual host, will not overwrite this setting; rather, it gets added to a stack of pages that will be attempted when the index is requested. This behaviour can be confirmed when you perform strace httpd -X and check the stat() calls right after the request has been read, e.g.:

stat("/path/to/vhost/index.html", 0x7fff9dc41b90) = -1 ENOENT
stat("/path/to/vhost/index.php", {st_mode=S_IFREG|0664, st_size=130, ...}) = 0

Although I can't tell exactly why, any previous DirectoryIndex directive must be cleared before specifying DirectoryIndex index.php, i.e. index.php MUST be the first page that's attempted to handle the request.

This can be done using the following configuration:

DirectoryIndex disabled
DirectoryIndex index.php
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.