KP Solutions

Solutions for Day to Day Technical Problems

Windows PHP with fcgi PHP_SELF invalid issue


Recently, I upgraded my laptop and I had to do a clean install. I decided to use PHP in fcgi mode instead of the regular module mode with Apache. With FCGI, there are obvious advantages. However, one disadvantage I found was that it required a lot of tweaking to get it done right.

Well, after been tweaked and ready for use, fcgi gave me a weird error where ‘PHP_SELF’ environment variable had wrong value. I had my apache root as “C:\server\www” and the PHP_SELF environment variable would have “C:\my_site\index.php”. This made absolutely no sense. I expected the PHP_SELF variable to be “C:\server\www\my_site\index.php”.

Considering the absurd behavior of php, I started digging into the the fcgi parameters and found that a param named “FcgidFixPathinfo” was the culprit. Initially, I had ‘FcgidFixPathinfo’ as ‘1’ and the paths were getting messed up. I changed it to ‘0’ and the paths were fixed.

Hence, ‘FcgidFixPathinfo’ param is not fixing the params, it is actually messing up the path. I wonder why would you need this variable. But nonetheless, if some one runs into this situation, hopefully he/she would find this post via Google before wasting an hour like me 🙂

Hope that helps.

Ketan Patel