PDA

View Full Version : PHP versions changing of the fly with no reason


priestjim
05-12-2009, 04:09 AM
Hi!

I am experiencing an extremely weird bug on LSWS 4.0.3! I am trying to run a wiki based on MediaWiki, which requires PHP5. My server, for various reasons defaults at PHP4. So I created an .htaccess file in the domain root and redefined the PHP version as following:

AddType application/x-httpd-php5 php php3 php4 php5 phtml

Now when I open the wiki's main page, I get this:


MediaWiki requires PHP 5.0.0 or higher. You are running PHP 4.4.9. [etc]

I've created an info.php to check the version out and it says I am running PHP 5.2.9. Digging deeper into the issue I found out that the "switching" occurs in the following line in includes/WebStart.php:

if ( (! function_exists( 'version_compare' ))
|| (version_compare( phpversion(), '5.0.0') < 0)) {
define( 'MW_PHP4', '1' );

placing a

phpinfo();
die();

before that line gives me 5.2.9. Placing it before define(..) gives me 4.4.9.

I cannot for the life of me figure this out, so any help would be welcome!

mistwang
05-12-2009, 09:57 PM
It is something impossible to me. :)
Maybe you put phpinfo() at both place, see if it changes in the middle of the script.

priestjim
05-13-2009, 12:45 AM
That's what I did! I got 2 different PHP versions! I'll PM you with system credentials to check it yourself out because I don't get how this could happen!

auser
05-13-2009, 10:55 AM
Hi priestjim,

put following test.php in your domain document root, what's the output?

<?php
echo "phpversion()=" . phpversion() . "<br>";
echo "version_compare( phpversion(), '5.0.0')=" . version_compare( phpversion(), '5.0.0')."<br>";
echo "phpversion()=" . phpversion() . "<br>";
?>

priestjim
05-13-2009, 11:18 AM
phpversion()=5.2.9
version_compare( phpversion(), '5.0.0')=1
phpversion()=5.2.9

mistwang
05-13-2009, 11:51 AM
I could not reproduce what you described. the PHP version is consistent. You can give it a try.

For subdomain, you should put the .htaccess under the document root, that's right way, not in the subdomain root directory.
LiteSpeed does not like Apache which go through all .htaccess along the path, most time, it starts from the document root directory.

mistwang
05-13-2009, 04:39 PM
It is a <LocationMatch /index.php> configuration in mod_security configuration, exclude.conf, causing trouble.
It works properly after commenting it out.

priestjim
05-14-2009, 12:52 AM
Indeed it works now! But why there was this conflict with mod_security? Even though the rule included index.php, I didn't see any strange rule overriding .htaccess files or so...

mistwang
05-14-2009, 11:12 AM
It is complicated, anyway, 4.0.4 build should have this addressed. You can give it a try.