SOLVED [CPANEL-23998] Wrong PHP version detected after version change when using PHP-FPM and LiteSpeed

dzamanakos

Well-Known Member
Feb 15, 2014
79
6
58
Larisa / Greece
cPanel Access Level
Root Administrator
Hi, i've posted that thread to litespeed forums, but believe that cpanel forum may be better to post, as adviced from a reply to my thread.

The following would apply not only to litespeed, but if i wanted for example to revert from php-fpm to suphp too.

i've used a test licence for litespeed and noticed a problem that forced me to revert back to apache and stop migrating to litespeed.
I'm on centos 7, latest whm and cloudlinux.

I've know from an older cpanel thread with the support that :
"The handler lines within the .htaccess are primarily designed to inform apache of the php versions when php-fpm is not in use; However, when php-fpm is in use the user configurations at /var/cpanel/userdata/username/domain.tld contain the actual php version "

As i'm using php-fpm (used suphp before) my accounts php version is stored in /var/cpanel/userdata/username/domain.tld
Every account has, in the document root of every domain, handlers in .htaccess that do not always match the running version of php, or have no handlers at all.

For example:
domain.com has phpversion: ea-php56 in /var/cpanel/userdata/username/domain.com, but AddType application/x-httpd-ea-php72 .php .php7 .phtml in .htaccess
domain.net has phpversion: ea-php70 in /var/cpanel/userdata/username/domain.net and an empty .htaccess

When reverting from apache to litespeed i understand that the .htaccess version of php is used in order litespeed to know which php version will use.
That resulted in many websites to show 500 errors, as some use ioncube for a specific php version, or use cms that need php5.6 to run.

Is there a way to rebuild the .htaccess handlers from the current php version of php-fpm, in order to continue the migration, so when litespeed is up, all the correct php version are on every domain (also subdomain/addon domain) .htaccess?

I thing that it would be great if cpanel synced .htaccess with /var/cpanel/userdata/username/domain.tld php versions every time a user changes the php version, so the correct version of php is used if change handlers.


best regards,
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello @dzamanakos,

Internal case CPANEL-23998 is open to address the issue where changing an account's PHP version (when PHP-FPM is enabled on the account) results in problems with PHP version detection when Litespeed is installed due to the way .htaccess files are read. I'll monitor this case and update this thread with more information as it becomes available. In the meantime, the temporary workaround is to manually remove the PHP version definitions from the .htaccess files in the document roots of the affected domains.

Additionally, another case (CPANEL-26248) is open to address the fact that PHP-FPM is shown as available and/or enabled when LiteSpeed is installed and running. This leads to confusion because LiteSpeed doesn't actually recognize or utilize PHP-FPM (it only uses LSPHP).

Thank you.
 
Last edited:

dzamanakos

Well-Known Member
Feb 15, 2014
79
6
58
Larisa / Greece
cPanel Access Level
Root Administrator
Thank you for your response.

The problem is, in some cases, that .htaccess shows the default version (php72), but the real version of the account is sometimes different.
If i delete the Addtype section, then the system's default php (php72) will be used and that will cause the same problem for users that have version<php72 .

Is it ok if i change by hand the :
AddType application/x-httpd-ea-php72 .php .php7 .phtml
to (for example) :
AddType application/x-httpd-ea-php56 .php .phtml
?
Will that work in order to migrate to litespeed?

I hope in the internal case, you will study a way to change existing accounts to the correct version (some servers have too many accounts to make it by hand), not only for the new ones.

best regards,
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
The problem is, in some cases, that .htaccess shows the default version (php72), but the real version of the account is sometimes different.
If i delete the Addtype section, then the system's default php (php72) will be used and that will cause the same problem for users that have version<php72 .
Hello @dzamanakos,

Can you open a support ticket so we can take a closer look at an affected system? You can post the ticket number here and we'll link this thread to it.

Thank you.
 

dzamanakos

Well-Known Member
Feb 15, 2014
79
6
58
Larisa / Greece
cPanel Access Level
Root Administrator
Hi, i hope in internal cases CPANEL-23998 and (CPANEL-26248) will cover the following scenario :

I used php-fpm before migrating to litespeed.
So all php versions are in /var/cpanel/userdata/username/domain.tld files.

Now i'm using litespeed.
As a cpanel user, I'm adding a subdomain (or addon domain, or a new cpanel account) for an account and in /home/user/subdomain.domain.com folder an .htaccess is created with add handler for php72 (system default).

I'm changing the php version through cpanel php manager to php 7.0

WHM thinks i'm using php-fpm and sets php 70 to /var/cpanel/userdata/username/subdomain.domain.com
The .htacces does not change and still shows the handler for php72
Litespeed reads .htaccess and executes scripts as php7.2

In order to use php 7.0 i have to delete the php handler from .htaccess.

best regards,
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello @dzamanakos,

Case CPANEL-23998 will fix that issue. It will make Apache PHP-FPM .htaccess settings compatible with LSAPI and it also fixes an issue where unnecessary .htaccess lines are added when Apache PHP-FPM is enabled (which results in breakage on the switch to LSAPI). I'll update this thread once it's published.

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello @dzamanakos,

The following document provides an overview of how MultiPHP interacts with the .htaccess file:

MultiPHP INI Editor for cPanel - Version 80 Documentation - cPanel Documentation

Provided you use MultiPHP INI Editor and MultiPHP Manager from the UI, the changes are automatically synced to the correct configuration file for the specific PHP handler assigned to the domain (e.g. .htaccess, php.ini).

Can you provide more information about why you'd like to see a change to the existing behavior after the issue reported on this thread is solved?

Thank you.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello @dzamanakos,

I've removed your earlier post per your request and I'll update this thread again once the referenced cases are published.

Thanks!
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello,

To update, here's the entry in the cPanel & WHM version 80 Change Log noting the fix for this issue:

Fixed case CPANEL-23998: Fix bug where unnecessary .htaccess lines were added when Apache PHP-FPM was enabled, resulting in breakage on switch to LSAPI.

You can see which versions are published to each Release Tier on the link below:

Latest cPanel & WHM Builds

Thank you.