I’m trying to get PHP4 running under CGI alongside PHP5 as a module in Apache. Long story short, I have some legacy applications that aren’t running under PHP5 and they would take a while to rewrite, so short term I should hopefully be able to run both PHP versions for now.

Most of the sites I’ve come across state that running one version as CGI and another as an Apache module is the best way to go about this. I’m pretty sure I have my httpd.conf setup properly as I’m no longer receiving “file not found” errors in my logs. Posting changes below for reference:

AddHandler php4-script .php4
Action php4-script "/cgi-bin/php4"
ScriptAlias /cgi-bin/ "/opt/lampp/cgi-bin/"

My current error is “Premature end of script headers: php4”. I’ve tried some diagnosis that I found here. If I run cgi-bin/php4 htdocs/test.php4 from the command prompt (where test.php4 is a simple echo phpinfo()), I get all the phpinfo data on screen, but no HTML formatting. I tried setting the PATH_TRANSLATE variable as the above link mentions and running cgi-bin/php4 but I never got any output doing that, possible issue could be this. Also I’ve checked and rechecked all my file permissions and everything looks good there.

Any other thoughts as to what I could be missing? Other option is to run another Apache instance on a different port, tried this at first but it started to get a bit messy, though I may have to revert to this.

1 Answer 1


see: http://www.deanspot.org/~alex/php5fcgi/index.html (Click on the symbol that looks like Theta, located in the right-bottom corner when you mouse over that area)

  • Thanks for the info. Ended up going with dual Apache however since I first posted this as I was having so many problems. Apr 15, 2011 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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