I have a very strange and fustrating problem. After two days of trying to figure out whether it was Apache or PHP I have come to the conclusion that PHP is causing the problem.
I downloaded and compiled PHP with the following configue line, with the intention of using it as a CGI with the Apache 2 web server.
./configure --enable-force-cgi-redirect \
--enable-discard-path --disable-short \
-tags --disable-ipv6 \
--with-openssl=/usr/local/ssl \
--enable-ftp --enable-mbstring
After installing I called PHP and sent it a file with the phpinfo() function and got the expected output on the command line. I then set up my virtual host to handle PHP requests:
<VirtualHost 192.168.0.2:80>
ServerName delves-s:80
DocumentRoot "/home/web/local/htdocs"
ErrorLog logs/delves_s-error_log
CustomLog logs/delves_s-access_log common env=!attack-attempt
# display email at bottom of error messages
ServerSignature EMail
# cgi config
ScriptAlias /cgi-bin/ "/home/web/local/cgi-bin/"
# php cgi config
AddHandler php-script .php
Action php-script "/cgi-bin/php"
</VirtualHost>
I put a copy of the php binary in the cgi-bin directory.
I then restarted the server and requsted a page in my document rroot with the phpinfo() function in. I was most surprised when instead of getting the PHP info page - the entire PHP binary was delievered to my browser.
At first I thought I had made a configuration error in Apache - which was causing it to send the actual cgi script rather than execute it. However, after numerous tests on other cgi scripts I discovered that PHP is being executed.
When I make my request for the PHP script the PHP binary is executed and the actual binary is parsed by PHP instead of the file. I have checked that Apache is setting all the appropriate envrionment variables and that it is passing cgi scripts the right data through stdard input.
Has anyone encountered this problem or know what maybe causing it? Is it a bug in PHP? Did I do something wrong at build time?
I am at a loss - as I have set up PHP for Apache loads of times and have never experienced this problem.
Thanks in advance for any help.