PHP versions changing of the fly with no reason

priestjim

Well-Known Member
#1
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:

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

PHP:
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!
 

priestjim

Well-Known Member
#3
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

Super Moderator
#4
Hi priestjim,

put following test.php in your domain document root, what's the output?
PHP:
<?php
echo "phpversion()=" . phpversion() . "<br>";
echo "version_compare( phpversion(), '5.0.0')=" . version_compare( phpversion(), '5.0.0')."<br>";
echo "phpversion()=" . phpversion() . "<br>";
?>
 

mistwang

LiteSpeed Staff
#6
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

LiteSpeed Staff
#7
It is a <LocationMatch /index.php> configuration in mod_security configuration, exclude.conf, causing trouble.
It works properly after commenting it out.
 

priestjim

Well-Known Member
#8
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...
 
Top