main httpd.conf and php.conf

Was wonder how these two play together?

I was having a problem having a site load up the right “index” file. It was loading an index.html instead of home.php.

I had home.php after index.html in the main file conf/httpd.conf, but on my live server the home.php is also on the DirectoryIndex line in the conf.d/php.conf file. After adding that in the test server worked as expected. I guess this case should never happen, not sure why I forgot to delete that index.html file, but just wanted to clear this up for future reference.

Apache reads the httpd.conf and processes each line sequentially. If you take a look at the /etc/httpd/conf/httpd.conf file, about 1/5th of the way down (right beneath the LoadModule directives), you’ll see this line:

Include conf.d/*.conf

As soon as it hits that line, it then “branches” out to the conf files in conf.d and reads those files (in alphabetical order). This is how Apache sees the conf.d/php.conf file, and eventually processes your DirectoryIndex line in the php.conf file.

As soon as it’s done reading the conf.d/*.conf files, it resumes processing the httpd.conf file. If you look further down (about another 200 lines), you’ll see something like:

DirectoryIndex index.html index.htm default.html default.htm

Both the DirectoryIndex lines in the conf/httpd.conf and the conf.d/php.conf are in the global scope (neither of them are enclosed in <Location> or <Directory> tags), so whichever one Apache sees last, wins. :slight_smile:

Thats what I thought, but for some reason putting the home.php in the php.conf makes it take preference over the httpd.conf DirectoryIndex.

Looks like we thought wrong :slight_smile:

http://issues.apache.org/bugzilla/show_bug.cgi?id=20414#c3