: Cloud Linux ea-php alt-php | MultiPHP PHP Selector



Rise Company
15-01-2024, 16:04
Cloud Linux ea-php alt-php | MultiPHP PHP Selector
cloud linux enable or disable PHP FPM
PHP Selector Integration with cPanel

Earlier, when EasyApache 3 was in trend, CloudLinux with PHP Selector would work seamlessly; you would set up the EasyApache profile which is compatible with PHP Selector, and you are ready to go. However, with EasyApache 4 cPanel introduced the built-in MultiPHP Manager which changed everything.

https://www.rise.company/forum/images/imported/2024/01/3.jpg

The main advantage of the MultiPHP Manager is allowing users to select different PHP versions for each domain.

With CloudLinux, you can also make use of a similar feature: PHP Selector. PHP Selector has an important advantage over MultiPHP Manager: it allows a single cPanel user to manage PHP extensions without the need to contact his/her hoster. The user can enable/disable PHP extensions as he pleases. PHP Selector also leaves the choice of PHP version to the end-user, but the switch is made for the whole user, not for a separate website (as with MultiPHP Manager).

The main question a hoster should answer is which of the above features he will provide for his clients: MultiPHP Manager or PHP Selector. Using both can be confusing for the end-users. You can manage which features to show to your cPanel end-users in WHM Home Packages Feature Manager Feature Lists.

If you'd like to use PHP Selector on a cPanel server, continue reading this document to understand how to integrate MultiPHP Manager and PHP Selector.

Prerequisites

Before integrating PHP Selector with cPanel,
make sure that you have the following components installed:


LVE Manager
CageFS
Our alt-php



Configuration

Once youre done with PHP Selectors installation, there are a few things that you need to check on cPanel servers. You need to make sure that MultiPHP Manager settings are correct and that CageFS is enabled for the users. Let us cover the steps in detail.
Go to WHM -> MultiPHP Manager -> PHP Versions tab.


https://www.rise.company/forum/images/imported/2024/01/4.jpg



Make sure that the System PHP Version is set to one of the ea-phpXX ones.
Attention: Selecting the alt-phpXX (as a System PHP Version) will break the PHP Selector.
Switch the PHP-FPM to Off; the PHP Selector is not compatible with it.
Note: If you have PHP-FPM enabled for existing websites, you need to disable it for them.
Last but not least, make sure that the domains/accounts (where you'd like to use the PHP Selector) use the Inherited version. You need to do that because MultiPHP Manager has a higher priority than PHP Selector. So, if any other PHP version is set in this menu, it will overwrite the PHP version selected in PHP Selector for that domain.

Thats it! You are all set. The only thing thats left is to make sure that you use the Enable for all users mode for CageFS if youd like to keep PHP Selector for all users. You can enable it via:
# /usr/sbin/cagefsctl --enable-all

Frequently Asked Questions (FAQ)

Q. How could I set the Inherited option for all new accounts/websites by default?

A. You wont have to; cPanel already sets the Inherited by default for all newly created accounts. You can find more information about the way PHP Inheritance works on this page.

Q. How could I set the Inherited option for all new accounts/websites when I transfer them from one server to another?

A. If after transferring users, they do not have Inherited version set in MultiPHP Manager, you can run this script to switch ALL domains on the server to Inherited version:
# for i in $(cut -d: -f1 /etc/userdatadomains );do whmapi1 php_set_vhost_versions version=inherit vhost-0=$i;done Attention! Be very careful with that script because it will change PHP versions for ALL domains on your server to inherited. If you are not sure that you want exactly this, use the WHM interface and manually select the domains you wish to switch PHP version for.

Q. What setup do you recommend for CL PHP Selector?

A. The recommended setup is the one described in the "Configuration" part of this guide. Additionally, if you are using the Apache web server, we recommend using mod_lsapi as PHP Handler. Install it using this guide. Enable it in WHM MultiPHP Manager Handlers.
Also, if you configured PHP Selector, we recommend disabling MultiPHP Manager for users. You can do that in Home Packages Feature Manager Feature Lists Manage feature list select Default and uncheck the box for MultiPHP INI Editor and MultiPHP Manager. This will stop your customers from seeing MultiPHP Manager/Editor which can be very confusing.

Q. Can I disable alt-phpXX versions from MultiPHP Managers dropdown list?

A. You can do so by editing the /opt/alt/alt-php-config/alt-php.cfg file. Once you edit it, run the following script:
/opt/alt/alt-php-config/multiphp_reconfigure.pyIt manages SCL prefixes for the Alt-PHP in /etc/scl/prefixes.

In this example, we keep the alt-php72 visible in the list only:

[MultiPHP Manager]
alt-php44 = no
alt-php51 = no
alt-php52 = no
alt-php53 = no
alt-php54 = no
alt-php55 = no
alt-php56 = no
alt-php70 = no
alt-php71 = no
alt-php72 = yes

Q. I dont want to use the PHP Selector, but Id like to select the alt-phpXX version for one account/website. Can I do that?

A. Sure. Youll need to choose the alt-phpXX in the MultiPHP Manager ➔ PHP Version here:


https://www.rise.company/forum/images/imported/2024/01/5.jpg

Please note that the PHP extensions set in the CloudLinux PHP Selector or CloudLinux Manager settings will not work in this case. You will only get the basic extensions that are built-in into a particular PHP version.

Q. I followed this guide, but the PHP version is still not fetched for my website from PHP Selector. What did I miss?

A. Make sure to check our Compatibility Matrix. It contains additional information on components that are incompatible with PHP Selector. E.g., you may need to remove mod_ruid2 to use our PHP Selector.

More about PHP Selectors configuration

Setting up the PHP version on customers end (in cPanel)

It is possible to change the current PHP Version for MultiPHP Manager on the users end.
Heres how the settings would look like by default:


https://www.rise.company/forum/images/imported/2024/01/6.jpg

The end-user can change that and select any version, other than Inherited one. Just like with WHMs MultiPHP Manager, the PHP Selector wont work correctly in this case. We recommend leaving either PHP Selector or MultiPHP Manager enabled for the end-user. That way, your end-users will have only one place where to configure PHP which will make things easier.

PHP directives and their priorities

Given the way cPanel handles the PHP versions, it could be quite confusing to understand which PHP.ini directive will get higher priority over another. Let's discuss it here.

Directives priority - If PHP Selector is enabled

If you use the PHP Selector (and it is configured according to this guide), its options would have the highest priority. You can find them in cPanel ➔ Select PHP Version ➔ Switch to PHP Options.

https://www.rise.company/forum/images/imported/2024/01/7.jpg

You can add custom php.ini options here too! Check this article to find out how to do that.
The lower priority would have the php.ini (or .user.ini for some of the PHP handlers) configuration file, but you could also type in the PHP values there.

Directives priority - If PHP Selector isnt used

If you havent configured the PHP Selector, and youd like to simply change PHP.ini parameters for particular alt-phpXX or ea-phpXX versions, you could manage them in WHM ➔ MultiPHP INI Editor. cPanel end-user can also customize php.ini directives in cPanel ➔ MultiPHP INI Editor. For more information, read the official documentation here and here.

PHP Version in the command-line interface (CLI)

Shell commands, starting with /usr/bin/php and /usr/local/bin/php would use the same version that you select in the PHP Selector (if its already set up). That PHP will also load PHP directives selected in PHP Selector. For example, if we have a setup like this:

https://www.rise.company/forum/images/imported/2024/01/8.jpg

We should get the 7.2 version in the php -v output if nothing was changed in the PHP Selector.This is exactly what we get:
/usr/local/bin/php -v
PHP 7.2.14 (cli) (built: Feb 10 2019 18:20:08) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.14, Copyright (c) 1999-2018, by Zend Technologies
But if we change the PHP version in the PHP Selector, the php -v output will change as well.

https://www.rise.company/forum/images/imported/2024/01/9.jpg

/usr/local/bin/php -v
PHP 7.3.2 (cli) (built: Feb 7 2019 13:36:44) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.2, Copyright (c) 1998-2018 Zend Technologies
However, PHP version chosen in MultiPHP Manager can also be applied to console commands /usr/bin/php and /usr/local/bin/php . Whether it will be applied or not depends on the current working directory. .htaccess file search is performed in the current directory and in parent directories. If the file is found, then the PHP version specified in it is applied, if not found, then System default PHP version is applied. System default PHP version for a specific user can be changed via PHP Selector.

:
https://cloudlinux.zendesk.com/hc/en-us/articles/360014084800-PHP-Selector-Integration-with-cPanel