Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to run PHP using FastCGI (mod-fcgid) under apache 2 with the worker MPM. I've used this blog post as a reference.

It seems I've got everything working except one thing:

When apache serves index.php implicitly (using mod_dir, I think), it does not use the configured handler for .php files, and just serves the PHP file as if it's static content.

However, when I add the index.php part manually to the URL, it does use the handler correctly and everything seems to work. Other PHP files work fine too.

To clarify:

What could cause this? Any hints are appreciated!


Edit: Some more details: this is on an Ubuntu intrepid system.

I got .php working in FastCGI by adding the two PHP lines to mods-enabled/fcgid.conf, so it now looks like:

<IfModule mod_fcgid.c>
  AddHandler    fcgid-script .fcgi
  IPCConnectTimeout 20
  AddHandler fcgid-script .php
  FCGIWrapper /usr/lib/cgi-bin/php5 .php
</IfModule>

Directory indices are configured in mods-enabled/dir.conf:

<IfModule mod_dir.c>
  DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

I didn't need to put Options +ExecCGI anywhere. Actually, I just tried commenting out the block in sites-enabled/000-default, and FastCGI PHP still works fine, except for implicit index.php

share|improve this question

3 Answers 3

I'm wondering whether your use of mod_index is by-passing the vhost for fastcgi (i.e. separate from the vhost that sets the use of the php handler).

share|improve this answer
    
If DirectoryIndex weren't configured correctly, it wouldn't serve his index.php as a plaintext file, it'd fall back to an index. –  chaos Jun 8 '09 at 21:09
    
Amended.________________________ –  Dana the Sane Jun 8 '09 at 21:22
    
Added some more details to the question. –  Tobi Jun 8 '09 at 21:55

This is possibly silly, but try:

<IfModule mod_fcgid.c>
   AddHandler    fcgid-script .fcgi
   IPCConnectTimeout 20
   AddHandler fcgid-script .php
   FCGIWrapper /usr/lib/cgi-bin/php5 .php
   DirectoryIndex index.php
</IfModule>

I've discovered a number of weirdness when Apache modules interact in odd ways. Certainly at times order in the config file is very important.

share|improve this answer
up vote 0 down vote accepted

Oh man, I've been very stupid.

Apparently I just had it misconfigured at one point in time, and my browser had cached the incorrect response.

http://example.com/index.php then worked, probably because I only started trying that after I had gotten FastCGI PHP working, so no incorrect response was in cache.

In other words, the information in my original question is a working configuration for mpm-worker + PHP in mod-fcgid!

Thanks for the effort anyway :-)

share|improve this answer

Your Answer

 
discard

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.