PHP Selector

PHP Selector is a CloudLinux component that sits on top of CageFS. It allows each user to select PHP version and module based on their needs. PHP Selector requires account to have CageFS enabled to work.

PHP Selector is compatible with the following technologies: suPHP, mod_fcgid, CGI (suexec), LiteSpeed .

It is not compatible with mod_php/DSO , including mod_ruid2 and MPM ITK .

Note

PHP Selector is not supported for H-Sphere.

Installation and Update

The installation of PHP Selector presumes that you already have CageFS & LVE Manager installed.

Use compatibility matrix to check if your Web Server/PHP mode is supporting PHP Selector. If not, you need a change to one of the supported models.

Installation of different versions of PHP & modules:

$ yum groupinstall alt-php

Update CageFS & LVE Manager with support for PHP Alternatives:

$ yum update cagefs lvemanager

cPanel/WHM : Make sure 'Select PHP version' is enabled in Feature Manager .

IMPORTANT : Please, do not use settings like SuPHP_ConfigPath, PHPRC, PHP_INI_SCAN_DIR . Do not redefine path to php.ini and ini-files for PHP modules. Doing that can break PHP Selector functionality.

For example, alternative php5.2 versions should load /opt/alt/php52/etc/php.ini file and scan /opt/alt/php52/etc/php.d directory for modules:

Configuration File (php.ini) Path         /opt/alt/php52/etc
Loaded Configuration File                 /opt/alt/php52/etc/php.ini
Scan this dir for additional .ini files   /opt/alt/php52/etc/php.d
additional .ini files parsed              /opt/alt/php52/etc/php.d/alt_php.ini

Those are default locations for alt-php .

If you need custom PHP settings per user, please change them via "Edit PHP settings" feature of PHP Selector .

If a list of default modules is absent on the server in the /etc/cl.selector/defaults.cfg file for some alt-PHP version and there is nd_mysqli extension in this version, then on installation/update of the LVE Manager, the mysqli extension will be disabled and nd_mysqli extension will be enabled automatically.

  • If nd_mysqli module is absent or a list of enabled modules is available, then they won't be changed automatically.
  • If alt-PHP is not installed on LVE Manager installation/update, then they won’t be changed automatically.

To change the modules status (enabled/disabled) manually, run the following command in a console:

# /usr/sbin/cloudlinux-selector make-defaults-config --json --interpreter=php

Update

To update PHP Selector, run the following command:

yum groupupdate alt-php

This command allows to install newly released versions in PHP Selector.

LiteSpeed support

Note

LiteSpeed detects CloudLinux OS and applies all settings out-of-the-box.

If the settings were not applied, you can use the following steps to set up LiteSpeed to use PHP Selector.

How to set up LiteSpeed version lower than 5.3 to use PHP Selector

To enable PHP Selector with LiteSpeed Web Server follow PHP Selector installation guide , and then adjust following settings in LiteSpeed :

  1. CloudLinux (Admin Console --> Configuration --> Server --> General): CageFS
  2. Enable SuExec: Server--> General --> PHP SuEXEC --> Yes
  3. Go to External App tab, the new lsphp_selector is here.

[Note that you can select any other application or create a custom one.]

  1. The Command line should be /var/www/cgi-bin/cgi_wrapper/cloudlinux_wrapper on Plesk . For other control panels, Command line should be /usr/local/bin/lsphp .

Run On Start Up line must contain Yes or No .

For Plesk :

For other control panels:

  1. Go to Script Handler tab. For required suffixes change the Handler Name to lsphp_selector .

Additional settings for LiteSpeed version 5.3 +

Go to Server --> PHP tab. Click Edit in the PHP Handler Defaults section. We recommend to set up the following settings:

  • Set Yes in the Run On Startup
  • Make sure to set Max Idle Time

Note

In order to use PHP Selector and custom php.ini, lsphp5 needs to be in SuEXEC non-daemon mode.

Note

Some PHP configurations require more memory for SuExec to work properly. If you are getting error 500 after switching suEXEC to non-daemon mode, try to increase Memory Soft Limit and Memory Hard Limit for external App to at least 650/800M.

Note

If you have LiteSpeed installed not in standard location path, please create a symlink: 'ln -s /path/to/custom/lsws /usr/local/lsws' then run 'cagefsctl --setup-cl-selector'.

ISPmanager support

As of July 2013, PHP Selector support for ISPmanager is limited to command line utilities. You should still be able to use it.

As always, PHP Selector requires CGI, FCGI or suPHP to work.

You will need to do following modifications:

Create new file /usr/local/bin/php-cgi-etc:

#!/bin/bash
/usr/bin/php-cgi -c /etc/php.ini "$@"
Make that file executable:
$ chmod +x /usr/local/bin/php-cgi-etc
Edit file /usr/local/ispmgr/etc/ispmgr.conf

Add a line:

path phpcgibinary /usr/local/bin/php-cgi-etc

Make sure there is no other lines with path phpcgibinary defined in the file.

Restart ISPmanager :

$ killall ispmgr

After that FCGID wrappers (/var/www/[USER]/data/php-bin/php) for new users will be like this:

#!/usr/local/bin/php-cgi-etc

You might need to edit/modify wrappers for existing users if you want them to be able to use PHP Selector . You can leave them as is for users that don't need such functionality.

Configuration

Setting Default Version and Modules

Administrator can set default interpreter version and extensions for all users. All file operations are actually done by CageFS. CageFS takes settings from /etc/cl.selector/defaults.cfg. Currently the /etc/cl.selector/defaults.cfg is created and handled by CloudLinux PHP Selector scripts. It has the following format:

[global]
selector=enabled

[versions]
php=5.4

[php5.4]
modules=json,phar

[php5.3]
modules=json,zip,fileinfo

Individual PHP.ini files

For each customer, inside CageFS, file alt_php.ini is located in /etc/cl.php.d/alt-phpXX (XX - version of PHP, like 52 or 53). The file contains PHP extension settings and extension directives selected by customer. This file exists for each customer, for each PHP version.

Note, that this is 'local' to CageFS, and different users will have different files. The file is not visible in /etc/cl.php.d outside CageFS. If you would like to view that file, use:

# cagefsctl -e USERNAME 

to enter into CageFS for that user. Then type: exit ; to exit from CageFS

This file has to be updated using cagefsctl --rebuild-alt-php-ini after updating alt-php RPMs

Admin can change individual settings for PHP extensions by changing that extension's ini file, like editing /opt/alt/php54/etc/php.d.all/eaccelerator.ini and then running:

cagefsctl --rebuild-alt-php-ini
to propagate the change.

How to add additional php.ini file for a user inside CageFS

If you want to create additional php.ini file for a user inside CageFS in order to change some specific PHP options for that user, you can execute the following:

# su -s /bin/bash - USER
# cd /etc/cl.php.d/alt-php72/
# echo "upload_tmp_dir=/tmp" >> custom.ini

The commands above create custom.ini file that will be used for alt-php72. By default this approach is valid only for alt-php version selected via PHP Selector. When /etc/cl.selector/symlinks.rules file contains php.d.location = selector line, then the approach is valid for all alt-php versions regardless whether it is selected in PHP Selector or not.

You can find more details here.

But the recommended way is to modify PHP options via PHP Selector web or CLI interfaces, as described here.

Substitute global php.ini for individual customer

Sometimes you might want to have a single customer with a different php.ini, than the rest of your customers.

To do that, you will use custom.etc directory functionality

  1. Move default php.ini into /etc directory and create a symlink to it:
$ mv /usr/local/lib/php.ini /etc/php.ini
$ ln -fs /etc/php.ini /usr/local/lib/php.ini
  1. Change path to php.ini in /etc/cl.selector/native.conf file to:
php.ini=/etc/php.ini
  1. For each user that needs custom file, create directory /etc/cagefs/custom.etc/USER_NAME/php.ini .

For example if you want to create custom for USER1 and USER2 you would create files:
/etc/cagefs/custom.etc/USER1/php.ini
/etc/cagefs/custom.etc/USER2/php.ini

Create such files for each user that should have custom file.

  1. Execute:
$ cagefsctl --force-update 

Notes

  1. Make sure that php.ini load path is set to /etc/php.ini

  2. Users will be able to override settings of those php.ini files (global or custom) via PHP Selector. If you want to prevent that, you should disable PHP Selector feature.

  3. Even if PHP Selector is disabled, user can override PHP settings by using ini_set() php function in PHP script, or by php -c command line option.

  4. If you modify anything in /etc/cagefs/custom.etc directory, you should execute:

$ cagefsctl --update-etc

in order to apply changes to CageFS for all users.

OR

$ cagefsctl --update-etc user1 user2

to apply changes to CageFS for specific users.

How to substitute global php.ini for individual customer on cPanel server with EasyApache4

Note

It is enough to put php.ini in the directory where PHP script is located in order to run the PHP script with a custom php.ini when using SuPHP. Also, you can use cPanel MultiPHP Manager to create user’s custom php.ini file, and this approach should work for CGI, FCGI, and LSAPI. Recommended ways to manage php.ini settings per user are to use cPanel MultiPHP or CloudLinux PHP Selector interfaces.

  1. For each user that needs custom file, create directory /etc/cagefs/custom.etc/USER_NAME/php.ini.

    For example, if you want to create a custom file for USER1 and USER2 you would create files:

    /etc/cagefs/custom.etc/USER1/php.ini
    /etc/cagefs/custom.etc/USER2/php.ini
    

    Create such files for each user that should have a custom file.

  2. Execute the following command:

    $ cagefsctl --force-update
    
  3. Configure php.ini load path for user’s domains.

  • When using suphp handler, you should use SuPHP_ConfigPath directive in virtual host configuration for these domains, or use this directive in .htaccess files: suPHP_ConfigPath/etc.

  • When using mod_lsapi, you should use lsapi_phprc directive in virtual host configuration: lsapi_phprc/etc/. You can find the detailed description of mod_lsapi directives here.

  • When using FCGI or CGI, you should implement custom PHP wrapper and redefine the path to php.ini via -c command line option, like below:

    #!/bin/bash
    [ -f /etc/php.ini ] && exec /usr/bin/php -c /etc/php.ini
    exec /usr/bin/php
    

Notes:

  1. You should restart Apache web server after modifying virtual host configuration for the domains.

  2. Custom php.ini may break switching PHP version via CloudLinux PHP Selector or cPanel MultiPHP Manager for the appropriate users or domains.

  3. When using cPanel ea-php for the domains, additional php.ini files may not be loaded, so you should load all needed PHP extensions in custom /etc/php.ini file:

  4. When using CloudLinux alt-php, additional php.ini files will be loaded:

  5. If you have modified anything in /etc/cagefs/custom.etc directory, you should execute one of the following:

    • to apply changes to CageFS for all users, run:
    $ cagefsctl --update-etc
    
    • to apply changes to CageFS for specific users, run:
    $ cagefsctl --update-etc user1 user2
    

Managing interpreter version

Managing interpreter versions is done by means of manipulating a set of symbolic links that point to different versions of interpreter binaries. For example, if default PHP binary is /usr/local/bin/php :

  • First we move the default binary inside CageFS to /usr/share/cagefs-skeleton/usr/selector , and make /usr/local/bin/php a symlink pointing to /etc/cl.selector/php . This operation is done as part of CageFS deployment.
  • Next suppose we have additional PHP version, say 7.2.5. The information about all additional interpreter binaries and paths for them is kept in /etc/cl.selector/selector.conf . This config file is updated by RPM package manager each time alternative PHP package is added, removed or updated
  • /usr/bin/selectorctl --list --interpreter=php will get us list of all available PHP interpreter versions out of /etc/cl.selector/selector.conf file . Next we want to know which PHP version is active for a given user (to supply a selected option in options list). We type:
  • /usr/bin/selectorctl --user USERNAME --interpreter=php --user-current will retrieve PHP version set for a particular user. The script gets the path from /var/cagefs/LAST_TWO_DIGITS_OF_UID/USERNAME/etc/cl.selector/php symlink, compares it with contents of /etc/cl.selector/selector.conf file and if path is valid, prints out the current interpreter version.
  • /usr/bin/selectorctl --user USERNAME --interpreter=php --set-user-current=7.2 sets the current PHP version for particular user by creating symlink in /var/cagefs/LAST_TWO_DIGITS_OF_UID/USERNAME/etc/cl.selector directory. All old symlinks are removed, and new symlinks are set.

Including PHP Selector only with some packages (cPanel)

cPanel has a ' Feature Manager ' in WHM that allows you to disable PHP Selector for some of the packages that you offer.

In reality it only disables the icon in cPanel interface. Yet, in most cases it should be enough in shared hosting settings.

You can find more info on ' Feature Manager ' here: http://docs.cpanel.net/twiki/bin/view/11_30/WHMDocs/FeatureManager

Once PHP Selector is enabled, you can find it in the Feature Manager . Disabling it in Feature Manager , will remove the icon for users that are using that particular 'Feature List'

PHP Extensions

Configuring Alt-PHP modules loading

CloudLinux PHP Selector and Alt-PHP can be used in conjunction with Plesk PHP Selector and cPanel MultiPHP . To be compatible, CloudLinux PHP Selector works as follows: modules that are selected in CloudLinux PHP Selector are loaded for Alt-PHP version selected in CloudLinux PHP Selector only. For the rest Alt-PHP versions default module set is loaded ( /opt/alt/phpXX/etc/php.d/default.ini ) . Described above is default behavior.

Note

If system default PHP version selected in cPanel MultiPHP Manager is not ea-php, then default module set is loaded for all Alt-PHP versions by default (/opt/alt/phpXX/etc/php.d/default.ini).

When "php.d.location = selector" option is in effect, modules selected via PHP Selector will be loaded for all alt-php versions.

This behavior is implemented in CageFS-6.1-10 and later.

In LVE Manager 1.0-9.40+ this behavior can be modified so that modules selected in CloudLinux PHP Selector would be loaded for all Alt-PHP versions (with CageFS enabled), which can be quite useful if you use  ‘ per directory ’ or ‘ per domain ’ Alt-PHP configuration and want to select modules using CloudLinux PHP Selector .

To modify it, create a file /etc/cl.selector/symlinks.rules (read-only for regular users) with the following content: php.d.location = selector

And run the command to apply changes:

/usr/bin/selectorctl --apply-symlinks-rules
To revert to the default behavior:
  • Delete /etc/cl.selector/symlinks.rules file.
  • Alternatively remove php.d.location option from the file.
  • Alternatively set default value for php.d.location option.

And run the command to apply changes:

/usr/bin/selectorctl --apply-symlinks-rules

FFmpeg

Due to possible patent issues CloudLinux does not provide FFmpeg libraries ( https://ffmpeg.org/legal.html ). We highly recommend researching if you can legally install FFmpeg extension on your server. This might differ based on where you and your servers are located. More information can be found on the link: https://ffmpeg.org/legal.html

For your convenience we provide FFMPEG PHP binding. For them to work, you need to install FFmpeg package from the “ Nux Dextop ” repository following the instructions.

Once FFmpeg is installed you can install PHP bindings, by running:

yum install alt-php*ffmpeg 

Enable PHP-FFmpeg extension via PHP Selector :

selectorctl --enable-extensions=ffmpeg --user USERNAME --version X.Y

Native PHP Configuration

PHP Selector requires access to the native PHP version for proper work. It is specified in the file /etc/cl.selector/native.conf of the following content (example):

php=/usr/bin/php-cgi
php-cli=/usr/bin/php
php.ini=/etc/php.ini
lsphp=/usr/local/bin/lsphp
php-fpm=/usr/local/sbin/php-fpm

Then execute the following command to apply changes.

cagefsctl --setup-cl-selector

The file is created when installing CageFS on the servers with cPanel, Plesk, DA, Interworx and ISP Manager , if it is missing. On all other servers the file is not being created at all.

That is why, if the file is not created automatically, then it must be created manually and correct paths must be written to its directives.

Access permission 644 must be set:

chmod 0644 /etc/cl.selector/native.conf

Command-line Tools

/usr/bin/cl-selector Tool is used to select version of PHP interpreter inside CageFS. Note. The command is obsolete, please use selectorctl instead.
/usr/bin/alt-php-mysql-reconfigure.py Reconfigures alt-php extensions to use correct MySQL library, based on the one installed in the system.

selectorctl

selectorctl is a new tool that replaces cl-selector (which is deprecated and should not be used anymore) and piniset . It is available starting with CageFS 5.1.3 .

All new features will be implemented as part of selectorctl .

Common Options

--interpreter (-i) : chooses the interpreter to work with. Currently only PHP is supported. If omitted, --interpreter=php is implied.
--version (-v) : specifies alternatives version to work with
--user (-u) : specifies user to take action upon.
--show-native-version (-V) : prints the version of native interpreter

Global Options

The global options modify settings in /etc/cl.selector/defaults.cfg file.

--list (-l) : lists all available alternatives for an interpreter. For instance on server with Alt-PHP installed, it produces the following output. Columns are: short alternative version, full alternative version and path to php-cgi binary.
$ selectorctl --list
5.2 5.2.17 /opt/alt/php52/usr/bin/php-cgi
5.3 5.3.28 /opt/alt/php53/usr/bin/php-cgi
5.4 5.4.23 /opt/alt/php54/usr/bin/php-cgi
5.5 5.5.7 /opt/alt/php55/usr/bin/php-cgi
--summary (-S) : prints alternatives state summary. Output format: alternative version, state ('e' for 'enabled', '-' otherwise), chosen as default one or not ('d' for 'default', '-' otherwise). For example:
$ selectorctl --summary
5.2 e -
5.3 e -
5.4 e -
5.5 e -
native e d
if used with --show-native-version displays version for native interpreter:
$ selectorctl --summary --show-native-version
5.2 e -
5.3 e -
5.4 e -
5.5 e -
native(5.3) e d
--current (-C) : prints currently globally selected default version (it is stored in /etc/cl.selector/defaults.cfg file):
$ selectorctl --current
native native /usr/bin/php
If used with --show-native-version , native interpreter version is displayed as well:
--current --show-native-version
native(5.3) native(5.3.19) /usr/bin/php
--set-current (-B): sets specified version as globally default one (in /etc/cl.selector/defaults.cfg file). For example, to set current default version of PHP to 5.4, use:
$ selectorctl --set-current=5.4
--disable-alternative (-N): adds state=disabled option to alternative section. With it a corresponding alternative gets removed from user alternatives selection list. For instance to disable PHP 5.2, run:
$ selectorctl --disable-alternative=5.2
--enable-alternative (-Y): Enables alternative version, removes state=disabled option, if present, from alternative section. For example to enable PHP 5.2:
$ selectorctl --enable-alternative=5.2
--enable-extensions (-E): enables extensions for particular PHP version by adding comma-separated list of extensions of modules for alternative in /etc/cl.selector/defaults.cfg . Requires --version option. For example:
$ selectorctl --enable-extensions=pdo,phar --version=5.2
--disable-extensions (-D): removes extensions for a particular PHP version. Comma-separated list of extensions will be removed from /etc/cl.selector/defaults.cfg . Requires --version . Example:
$ selectorctl --disable-extensions=pdo,phar --version=5.2
--replace-extensions (-R): replaces all extensions for particular PHP version to the list of comma separated extensions. Requires --version option . Example:
$ selectorctl --replace-extensions=pdo,phar --version=5.2
--list-extensions (-G): lists extensions for an alternative for a particular version. Requires --version . Example:
$ selectorctl --list-extensions --version=5.3
~ xml
- xmlreader
- xmlrpc
- xmlwriter
- xrange
+ xsl
Plus sign (+) stands for 'enabled', minus (–) for 'disabled', tilde (~) means compiled into interpreter. Enabled and disabled state relates to presence in /etc/cl.selector/defaults.cfg file.

End User Options

All end-user settings are contained in individual user's alt_php.ini files and controlled using selectorctl command.

--user-summary (-s): prints user alternatives state summary. Example:
$ selectorctl --user-summary --user=user1
5.2 e - -
5.3 e - -
5.4 e - -
5.5 e - -
native e d s
Columns are: alternative version, state ('e' for 'enabled', '-' otherwise), chosen as default one or not('d' for 'default', '-' otherwise), selected as user default one or not ('s' for 'selected', '-' otherwise). If used with --show-native-version , version for native interpreter is shown in parenthesis:
$ selectorctl --user-summary --user=user1 --show-native-version
5.2 e - -
5.3 e - -
5.4 e - -
5.5 e - -
native(5.3) e d s
--user option is required.
--current (-c): prints currently globally selected default version (in /etc/cl.selector/defaults.cfg file):
$ selectorctl --current
5.3 5.3.28 /opt/alt/php53/usr/bin/php-cgi
If used with --show-native-version to display native version:
$ selectorctl --user-current --user=user1
5.3 5.3.28 /opt/alt/php53/usr/bin/php-cgi
--user option is required.
--set-user-current (-b): sets specified version as the one to use for this end user:
$ selectorctl --set-user-current=5.4 --user=user1
changes user symlinks for the PHP interpreter to point to alternative 5.4.
--user option is required.
--enable-user-extensions (-e): Enables comma-separated list of extensions for the user user. Information is saved to alt_php.ini file. Requires --version and --user options.
$ selectorctl --enable-user-extensions=pdo,phar --version=5.2 --user=user1
--disable-user-extensions (-d): Disables extensions provided as comma-separated list. Requires --version and --user options.
$ selectorctl --disable-user-extensions=pdo,phar --version=5.2 --user=user1
--replace-user-extensions (-r): Replaces extensions with a provided comma-separated list of extensions Requires --version and --user options:
$ selectorctl --replace-user-extensions=pdo,phar --version=5.2 --user=user1
--reset-user-extensions (-t): Resets extensions for end user to default list of extensions as defined in default.cfg . Requires --version and --user options.
$ selectorctl --reset-user-extensions --version=5.2 --user=user1
--list-user-extensions (-g): lists enabled user extensions for an alternative. Requires --version and --user options.
$ selectorctl --list-user-extensions --version=5.3 --user=user1
xml
xmlreader
xmlrpc
if --all option present, command will list all alternatives extensions marked enabled or disabled for given user. For example:
$ selectorctl --list-user-extensions --version=5.3 --user=user1 --all
- xmlreader
- xmlrpc
- xmlwriter
- xrange
+ xsl
Plus sign (+) stands for 'enabled', minus (–) stands for 'disabled'. Enabled and disabled state relates to presence or absence of corresponding extensions in user alt_php.ini file.
--add-options (-k): adds options (as in php.ini ) to user alt_php.ini file. For example:
$ selectorctl --add-options=log_errors:on,display_errors:on --version=5.2 --user=user1
adds log_error and display_errors options with values 'on' to user alt_php.ini file overwriting default values for a user. Requires --version and --user options.
--replace-options (-m): replaces all options in user alt_php.ini file with specified ones. Requires --version and --user options.
$ selectorctl --replace-options=log_errors:on,display_errors:on --version=5.2 --user=user1
--delete-options (-x): removes custom options from user alt_php.ini file. Requires --version and --user options.
$ selectorctl --delete-options=log_errors,display_errors --version=5.2 --user=user1
--print-options (-P): print options from /etc/cl.selector/php.conf file with default values or ones overwritten in user's alt_php.ini file.
$ selectorctl --print-options --version=5.2 --user=user1
TITLE:allow_url_fopen
DEFAULT:On
COMMENT:Allows PHP file functions to retrieve data from remote
locations over FTP or HTTP. This option is a great security risk,
thus do not turn it on without necessity.
TYPE:bool
...
Requires --user option. --version option is optional. When --version is omitted, options for current selected version will be printed. By default outputs as plain test. If --json , --csv , --perl is specified, outputs data in corresponding format. For example, with --perl option, the output is perl hash structure that can be evaluated.
--reset-options (-z): removes custom options from alt_php.ini files for ALL users and versions. Backup files in home folders are cleared.
$ selectorctl --reset-options
The ranges of affected customers or versions can be narrowed with --version or --user options :
$ selectorctl --reset-options --user=user1,user2 --version=5.3,5.4
--list-users (-L): list users that use particular version of interpreter, specified with --version option. For example, to see all users that use PHP version 5.3:
$ selectorctl --list-users --version=5.3
--change-to-version (-T): changes all (or particular user) from one interpreter version to another.
$ selectorctl --change-to-version=5.2 --version=5.3

Additional Options

--base64 (-Q) Sometimes PHP options values can contain commas and other symbols that break command line formatting. In such a case convert a key:value pair into base64 and pass it as value for option-related arguments. For example, to add disable_functions=exec,popen,system and display_errors=on to user options, do the following:
$ selectorctl --add-options=echo disable_functions:exec,popen,system|base64 -w 0,echo display_errors:on|base64 -w 0 --version=5.2 --user=user1 --base64
Option -w 0 of base64 executable stands for 'disable wrapping of lines' . Without it base64 output will break the command.
--quiet makes selectorctl continue when it encounter option not found in php.conf . Without it selectorctl exits with error.

Integrating With Control Panels

This is the list of commands that we use to integrate PHP Selector with control panels. If you need to integrate PHP Selector with a custom control panel, you might find all the commands here:

PHP summary:

Command:

/usr/bin/selectorctl --summary
Result:
4.4 e -
5.1 e -
5.2 e -
5.3 e -
5.4 e -
5.5 e -
5.6 e -
7.0 e -
7.1 e -
native e d
When native PHP version needs to be displayed:

Command:

/usr/bin/selectorctl --summary --show-native-version

Result:

4.4 e -
5.1 e -
5.2 e -
5.3 e -
5.4 e -
5.5 e -
5.6 e -
7.0 e -
7.1 e -
native(5.6) e d

The first column: PHP version
The second column: enabled or not ( e - enabled)
The third column: if selected as default ( d - default)

Set default version:

/usr/bin/selectorctl --set-current=_VERSION_

Disable version:

/usr/bin/selectorctl --disable-alternative=_VERSION_

Enable version:

/usr/bin/selectorctl --enable-alternative=_VERSION_

List Extensions for a version:

/usr/bin/selectorctl --list-extensions --version=5.6

Result:

- apc
- bcmath
- big_int
- bitset
- bloomy
~ bz2
- bz2_filter
~ calendar
- coin_acceptor
- crack
~ ctype
+ curl

+: enabled
~: included in php binary (cannot be disabled)
-: disabled

Select Default Extensions (enable comma-separated list of extensions globally for a version):

/usr/bin/selectorctl --version=5.6 --enable-extensions=pdo,json,mysql

Deselect Default Extensions (disable comma-separated list of extensions globally for a version):

/usr/bin/selectorctl --version=5.6 --disable-extensions=pdo,json,mysql

Replace extensions with comma-separated list of extensions for a version globally:

/usr/bin/selectorctl --version=5.6 --replace-extensions=pdo,json,mysql

Select PHP version for a user:

/usr/bin/selectorctl --set-user-current=_VERSION_ --user=_USER_

List Enabled extensions for a user:

/usr/bin/selectorctl --list-user-extensions --user=_USER_ --version=_VERSION_

Enable comma-separated list of extensions for a user:

/usr/bin/selectorctl --enable-user-extensions=pdo,json,mysql --user=_USER_ --version=_VERSION_

Reset user’s extensions to defaults:

/usr/bin/selectorctl --reset-user-extensions --user=_USER_ --version=_VERSION_

Replace user extensions with comma-separated list of extensions:

/usr/bin/selectorctl --replace-user-extensions=EXT_LIST --user=_USER_ --version=_VERSION_

EXT_LIST a is comma separated list of PHP extensions (for example: pdo,json,mysql )

List available options for php.ini editing:

/usr/bin/selectorctl --print-options --user=_USER_ --version=_VERSION_ [--json]

List available options for php.ini editing (print safe strings):

/usr/bin/selectorctl --print-options-safe --user=_USER_ --version=_VERSION_ [--json]

Set php.ini options for end user:

/usr/bin/selectorctl --user=_USER_ --version=_VERSION_ --replace-options=_OPTIONS_ --base64 [--json]

Here is an example of how you can generate OPTIONS in base64 format:

OPTIONS=`echo disable_functions:exec,syslog|base64 -w 0`,`echo display_errors:off|base64 -w 0`,`echo post_max_size:128M|base64 -w 0`
echo $OPTIONS

Removing

It is not possible to remove PHP Selector from the system completely as it is an essential part of LVE Manager and CageFS packages. However, you can make PHP Selector unavailable for cPanel and Plesk users.

To do so, go to LVE Manager → PHP Selector and check Disabled as PHP Selector status. Doing so allows you to disable web-interface of the PHP Selector in the user interface but does not reset custom settings (choosing a version of PHP and modules).

To disable PHP Selector and make it has no effect on a PHP version on the sites, run the following command:

  • this command resets PHP versions to Native:
cagefsctl --cl-selector-reset-versions
  • this command resets PHP modules to Default:
cagefsctl --cl-selector-reset-modules

WARNING

These commands can affect PHP version of your clients’ web sites. Use them with caution as improper usage might cause your clients’ web sites down.

Using

Once PHP Selector is installed, you will see the Selector tab in the LVE Manager.

PHP Selector lets you select default PHP version, as well as modules that will be available to user out of the box.

Inside cPanel , User will be able to change PHP version they would have:

as well as extensions that they want to use:

and php.ini settings

All changes are saved automatically.

Custom PHP.ini options

[Requires LVE Manager 0.6+]

PHP Selector allows customer to edit php.ini settings. Admin has a full control over which settings can be modified.

To allow settings to be modifiable, it has to be whitelisted in /etc/cl.selector/php.conf .

Here are some of the examples of allowed directives:

Directive = safe_mode
Default   = Off
Type      = bool
Remark    = <5.4.0
Comment   = Enables PHP safe mode. This mode puts a number of restrictions on scripts (say, access to file system) mainly for security reasons.
Directive = safe_mode_include_dir
Type      = value
Remark    = <5.4.0
Comment   = If PHP is in the safe mode and a script tries to access some files, files from this directory will bypass security (UID/GID) checks. The directory must also be in include_path. For example: /dir/inc
Directive php.ini setting
Default Default value
Type bool, value (any text), list
Range list of values for list Type
Comment explanation of the setting to display in UI

Default values, that are shown in PHP Selector web interface, are taken from '/opt/alt/phpXX/usr/bin/php -i' runtime values, if directive is not there, it will use ' default ' value that was set in php.conf . So, if you wish to change default value of any option for "alternative" php version, please modify /opt/alt/phpXX/etc/php.ini files (where XX = 55, 54, 53, etc according to php version).

Admin can modify the settings using selectorctl command.

Users can use web interface to modify php.ini settings:

End user files and directories

The following files and directories are created inside CageFS for each customer:

/etc/cl.selector - PHP binaries symbolic links.

/usr/selector/php - Native PHP binaries.

/etc/cl.php.d/alt-php* - Links to enabled modules.

/home/user/.cl.selector/alt_phpXX.cfg - Config file for custom PHP options.

like:

/etc/cl.php.d/alt-php54/fileinfo.ini - /opt/alt/php54/etc/php.d.all/fileinfo.ini

Compiling your own extensions

Sometimes you might want to compile your own PHP extension for your users to use. In most cases, it is better to contact our support by sending us a support ticket . We will try to provide such extension for you via regular updates within 5-7 days.

If you have decided that you want to build it on your own, you would need to build it for each and every supported version of PHP that you have installed. The module installation process is a bit different from standard - you would need to use the version of phpize and php-config binaries that come with particular Alt-PHP version.

The full process for PHP 5.X and 7.X looks as follows:

  1. Download and unpack extension, cd into it's directory.

  2. Execute our version of phpize if necessary:

/opt/alt/phpXX/usr/bin/phpize
  1. Execute configure with our binary:
./configure --with-php-config=/opt/alt/phpXX/usr/bin/php-config
  1. Make the .so file:
make
  1. Copy it to the modules directory (on 32-bit server, use usr/lib/php/modules ).
cp -rp modules/*.so /opt/alt/phpXX/usr/lib64/php/modules/
  1. Add ini file for module to /opt/alt/phpXX/etc/php.d.all .

  2. Register new Alt-PHP version with:

$ cagefsctl --setup-cl-selector

Roll your own PHP

To add your own PHP version in PHP Selector :

  • Create directory in (like: /opt/alt/php51), and mimic directory structure inside to be similar to the one of PHP versions bundled by CloudLinux .
  • Put all the ini files for all the modules into /opt/alt/php51/etc/php.d.all
  • Create a symbolic link /opt/alt/php51/etc/php.d -> /etc/cl.php.d/alt-php51

Place all such files into /opt/alt/php51/usr/lib/php/modules

Add an absolute path to PHP binaries into /etc/cl.selector/selector.conf using the following format:

php     5.1 5.1.2 /opt/alt/php51/usr/bin/php-cgi 
php-cli 5.1 5.1.2 /opt/alt/php51/usr/bin/php 
php-fpm 5.1 5.1.2 /opt/alt/php51/usr/sbin/php-fpm
   ^     ^    ^                ^----- absolute path
   |     |    |---------------------- real version
   |     | -------------------------- version to display
   |--------------------------------- binary to 'substitute'

Execute:

cagefsctl --setup-cl-selector

The new PHP version must be available now for selection in PHP Selector .

Detect User's PHP Version

[ LVE Manager 0.5-63 or higher]

PHP Selector provides an easy way to figure out which versions are available and selected for end user from the command line. You can get this information by running:

$ selectorctl --interpreter=php --user-summary --user=USERNAME
The output:
5.2 e - -
5.3 e - s
5.4 e - -
5.5 e - -
native e d -

The first column defines the PHP version. Native means native PHP version, like the one installed by cPanel with EasyApache.

The second column will contain either e or -. If e is present, it means that given version is enabled, and can be selected by the end user.

The third column can have values d or -. If d is present, that version is considered a 'default' version. Only one PHP version will have d indicator.

The fourth column can have values s or -. If s is present, that is the selected version, currently being used by the end user. Only one PHP version will have s indicator.

In case a user is not inside CageFS, and as such doesn't use PHP Selector , you will see the following error message:

ERROR:User USERNAME not in CageFS

PHP Selector without CageFS

[LVE Manager 2.0-11.1 or higher]

PHP Selector can now be used with CageFS turned off (in case when there is only one user account on the server).

To install run:

yum groupinstall alt-phpyum install cagefs lvemanager

(no need to initialize or turn on CageFS)

selectorctl --setup-without-cagefs USER

( USER - the name of a user who is using selector. If not specified, the first available cPanel account username will be used).

When executing --setup-without-cagefs , the following actions are performed:

  • Creating symlinks to the user modules and options for each Alt-PHP version:
    /opt/alt/php55/link/conf/alt_php.ini -> /home/USER/.cl.selector/alt_php55.ini

  • In user home directory creating:
    .cl.selector/

“Backup” settings files (selected version, modules, options):
.cl.selector/defaults.cfg
.cl.selector/alt_php44.cfg

Symlinks to the selected version:
.cl.selector/lsphp -> /opt/alt/php44/usr/bin/lsphp
.cl.selector/php.ini -> /opt/alt/php44/etc/php.ini
.cl.selector/php-cli -> /opt/alt/php44/usr/bin/php
.cl.selector/php -> /opt/alt/php44/usr/bin/php-cgi

Additional symlinks for environment variable $PATH (search path) in the file ~/.bashrc :
.cl.selector/selector.path/
.cl.selector/selector.path/php-cgi -> ../php
.cl.selector/selector.path/php -> ../php-cli

Generated ini files with selected modules and options for each version: .cl.selector/alt_php44.ini
.cl.selector/alt_php51.ini
.cl.selector/alt_php52.ini
.cl.selector/alt_php53.ini
.cl.selector/alt_php54.ini
.cl.selector/alt_php55.ini
.cl.selector/alt_php56.ini
.cl.selector/alt_php70.ini
.cl.selector/alt_php71.ini

Symlinks above are being created according to the settings in ~/.cl.selector/defaults.cfg and ~/.cl.selector/alt_php44.cfg files (44 - corresponding PHP version), which are storing PHP Selector settings for the user. These files are usually taken from user home directory backup or when migrating account from another server. Thus, when migrating account from server to server, PHP Selector settings are saved.

If no PHP Selector settings backup files are found when running selectorctl --setup-without-cagefs , then default settings from /etc/cl.selector/defaults.cfg global file are applied (as in selector normal mode). If the file is absent, then native PHP version will be selected for the user.

  • The following line: PATH=$HOME/.cl.selector/selector.path:$HOME/.cl.selector:$PATH

is being added to the user file ~/.bashrc

Apache PHP handlers settings are not changed.

  • Also selectorctl --setup-without-cagefs command does the following:

    • Turns off link traversal protection (linksafe);
    • Turns off cagefs service.

To get back to the selector normal mode (“with CageFS”) run:

selectorctl --revert-to-cagefs

(CageFS should be initialized by using “cagefsctl --init” command before running the command above)

This command removes symlinks:
/opt/alt/php55/link/conf/alt_php.ini -> /home/USER/.cl.selector/alt_php55.ini, turns on link traversal protection (linksafe) and cagefs service.

Configuring "Global” php.ini options for all Alt-PHP Versions

[CageFS 6.0-33 or higher, LVE Manager 2.0-11.2 or higher]

There is /etc/cl.selector/global_php.ini file, where you can specify values of PHP options that should be applied for all Alt-PHP versions that are installed on a server. These settings will also be automatically applied to the new Alt-PHP versions that will be installed later.

Example:
# cat /etc/cl.selector/global_php.ini
[Global PHP Settings]
date.timezone = Europe/Warsaw
error_log = error_log
memory_limit = 192M
Sections are ignored. Only name of an option and a value have meaning.

When an option is absent in /etc/cl.selector/global_php.ini file, than it is not changed (applied) to php.ini for Alt-PHP versions.

date.timezone and error_log options are handled differently than the others. When these options are not in /etc/cl.selector/global_php.ini file, than values for the options will be taken from "native" php.ini file. And when the option is in php.ini for some Alt-PHP version already (and its value is not empty), than value from /etc/cl.selector/global_php.ini will be NOT applied.

[CageFS version 6.1.5-1 or later]

The behavior above is changed for cPanel servers with EasyApache 4. The /usr/local/lib/php.ini file is removed for new installations of cPanel v80 and later.

  • When /usr/local/lib/php.ini file exists, error_log and date.timezone options will be taken from that php.ini file.
  • When /usr/local/lib/php.ini file does not exist, error_log and date.timezone options will be taken from the php.ini file for system default PHP version selected in MultiPHP Manager.

This functionality works when the system default PHP version is ea-php only. When the system default PHP version is alt-php, error_log and date.timezone directives will be NOT taken from that php.ini file.

To confirm changes (not affecting "date.timezone" and "error_log" options) please run:

/usr/sbin/cagefsctl --setup-cl-selector

To confirm changes (including "date.timezone" and "error_log" options) please run:

/usr/bin/selectorctl --apply-global-php-ini
or
/usr/sbin/cagefsctl --apply-global-php-ini
(two commands above work the same way).

If you don't want to change error_log , but want to change date.timezone , you can execute:

selectorctl --apply-global-php-ini date.timezone

Similarly, command selectorctl --apply-global-php-ini error_log applies error_log and all other options specified in /etc/cl.selector/global_php.ini file, except date.timezone .

So, you can specify 0, 1 or 2 parameters from the list: error_log, date.timezone .

Using --apply-global-php-ini without arguments applies all global PHP options including two above.

Example:

selectorctl --apply-global-php-ini error_log
selectorctl --apply-global-php-ini date.timezone
selectorctl --apply-global-php-ini date.timezone error_log

The latter command has the same effect as /usr/bin/selectorctl --apply-global-php-ini

Bundled PHP Extensions

Large number of PHP extensions are bundled with each version of PHP:

PHP 4.4 Extensions

bcmath
bz2
calendar
ctype
curl
dba
dbase
dbx
domxml
exif
fileinfo
ftp
gd
gettext
gmp
iconv
imap
interbase
ioncube_loader
ioncube_loader_4
json
ldap
mbstring
mcrypt
mhash
mysql
ncurses
odbc
openssl
overload
pcntl
pcre
pgsql
posix
pspell
readline
recode
session
shmop
snmp
sockets
sourceguardian
standard
sybase_ct
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlrpc
zlib

PHP 5.1 Extensions

bcmath
big_int
bitset
bz2
bz2_filter
calendar
coin_acceptor
crack
ctype
curl
date
dba
dbase
dom
doublemetaphone
exif
ftp
gd
geoip
gettext
gmagick
gmp
gnupg
haru
hash
huffman
iconv
idn
igbinary
imagick
imap
inclued
inotify
interbase
ioncube_loader
ioncube_loader_4
ldap
libxml
lzf
mbstring
mcrypt
memcache
msgpack
mysql
mysqli
ncurses
odbc
openssl
pcntl
pcre
pdo
pdo_firebird
pdo_mysql
pdo_odbc
pdo_pgsql
pdo_sqlite
pgsql
posix
pspell
quickhash
radius
readline
redis
reflection
session
shmop
simplexml
snmp
soap
sockets
sourceguardian
spl
ssh2
standard
stats
stem
sybase_ct
sysvmsg
sysvsem
sysvshm
tidy
timezonedb
tokenizer
translit
wddx
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xsl
zlib

PHP 5.2 Extensions

apc
apm
ares
bcmath
bcompiler
big_int
bitset
bloomy
bz2
bz2_filter
calendar
coin_acceptor
crack
ctype
curl
date
dba
dbase
dbx
dom
doublemetaphone
eaccelerator
enchant
exif
ffmpeg
fileinfo
filter
ftp
gd
gender
geoip
gettext
gmagick
gmp
gnupg
haru
hash
hidef
htscanner
huffman
iconv
idn
igbinary
imagick
imap
inclued
inotify
interbase
intl
ioncube_loader
ioncube_loader_4
json
ldap
libxml
lzf
magickwand
mailparse
mbstring
mcrypt
memcache
memcached
mhash
mongo
msgpack
mssql
mysql
mysqli
ncurses
oauth
odbc
opcache
openssl
pcntl
pcre
pdf
pdo
pdo_dblib
pdo_firebird
pdo_mysql
pdo_odbc
pdo_pgsql
pdo_sqlite
pgsql
phar
posix
pspell
quickhash
radius
rar
readline
recode
redis
reflection
rsync
session
shmop
simplexml
snmp
soap
sockets
sourceguardian
spl
spl_types
sqlite
ssh2
standard
stats
stem
stomp
suhosin
sybase_ct
sysvmsg
sysvsem
sysvshm
tidy
timezonedb
tokenizer
translit
uploadprogress
uuid
wddx
xcache_3
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xrange
xsl
yaf
yaz
zend_optimizer
zip
zlib

PHP 5.3 Extensions

apc
apcu
apm
ares
bcmath
bcompiler
big_int
bitset
bloomy
brotli
bz2
bz2_filter
calendar
clamav
coin_acceptor
core
crack
ctype
curl
date
dba
dbase
dbx
dom
doublemetaphone
eaccelerator
eio
enchant
ereg
exif
ffmpeg
fileinfo
filter
ftp
functional
gd
gender
geoip
gettext
gmagick
gmp
gnupg
haru
hash
hidef
htscanner
http
huffman
iconv
idn
igbinary
imagick
imap
inclued
inotify
interbase
intl
ioncube_loader
ioncube_loader_4
jsmin
json
ldap
libevent
libxml
lzf
magickwand
mailparse
mbstring
mcrypt
memcache
memcached
mhash
mongo
msgpack
mssql
mysql
mysqli
mysqlnd
ncurses
nd_mysql
nd_mysqli
nd_pdo_mysql
oauth
odbc
opcache
openssl
pcntl
pcre
pdf
pdo
pdo_dblib
pdo_firebird
pdo_mysql
pdo_odbc
pdo_pgsql
pdo_sqlite
pgsql
phalcon
phar
posix
propro
pspell
quickhash
radius
raphf
rar
readline
recode
redis
reflection
rsync
session
shmop
simplexml
snmp
soap
sockets
sourceguardian
spl
spl_types
sqlite
sqlite3
ssh2
standard
stats
stem
stomp
suhosin
sybase_ct
sysvmsg
sysvsem
sysvshm
tidy
timezonedb
tokenizer
trader
translit
uploadprogress
uri_template
uuid
wddx
weakref
xcache
xcache_3
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xrange
xsl
yaf
yaml
yaz
zend_guard_loader
zip
zlib
zmq

PHP 5.4 Extensions

apc
apcu
apm
ares
bcmath
big_int
bitset
brotli
bz2
bz2_filter
calendar
clamav
core
ctype
curl
date
dba
dbase
dbx
dom
doublemetaphone
eaccelerator
eio
enchant
ereg
exif
ffmpeg
fileinfo
filter
ftp
functional
gd
gender
geoip
gettext
gmagick
gmp
gnupg
haru
hash
hidef
htscanner
http
iconv
igbinary
imagick
imap
inclued
inotify
interbase
intl
ioncube_loader
ioncube_loader_4
jsmin
json
ldap
libevent
libsodium
libxml
lzf
magickwand
mailparse
mbstring
mcrypt
memcache
memcached
mhash
mongo
mongodb
msgpack
mssql
mysql
mysqli
mysqlnd
ncurses
nd_mysql
nd_mysqli
nd_pdo_mysql
oauth
oci8
odbc
opcache
openssl
pcntl
pcre
pdf
pdo
pdo_dblib
pdo_firebird
pdo_mysql
pdo_odbc
pdo_pgsql
pdo_sqlite
pgsql
phalcon
phar
posix
propro
pspell
quickhash
radius
raphf
rar
readline
recode
redis
reflection
rsync
session
shmop
simplexml
snmp
soap
sockets
sourceguardian
spl
spl_types
sqlite3
ssh2
standard
stats
stem
stomp
suhosin
sybase_ct
sysvmsg
sysvsem
sysvshm
tidy
timezonedb
tokenizer
trader
translit
uploadprogress
uri_template
uuid
wddx
weakref
xcache
xcache_3
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xrange
xsl
yaf
yaml
yaz
zend_guard_loader
zip
zlib
zmq

PHP 5.5 Extensions

apcu
apm
ares
bcmath
big_int
bitset
brotli
bz2
bz2_filter
calendar
clamav
core
ctype
curl
date
dba
dbase
dbx
dom
doublemetaphone
eio
enchant
ereg
exif
ffmpeg
fileinfo
filter
ftp
gd
gender
geoip
gettext
gmagick
gmp
gnupg
gRPC
haru
hash
hidef
htscanner
http
iconv
igbinary
imagick
imap
inotify
interbase
intl
ioncube_loader
ioncube_loader_4
jsmin
json
ldap
libevent
libsodium
libxml
lzf
magickwand
mailparse
mbstring
mcrypt
memcache
memcached
mhash
mongo
mongodb
msgpack
mssql
mysql
mysqli
mysqlnd
ncurses
nd_mysql
nd_mysqli
nd_pdo_mysql
oauth
oci8
odbc
opcache
openssl
pcntl
pcre
pdf
pdo
pdo_dblib
pdo_firebird
pdo_mysql
pdo_odbc
pdo_pgsql
pdo_sqlite
pgsql
phalcon
phalcon3
phar
posix
propro
pspell
quickhash
radius
raphf
rar
readline
recode
redis
reflection
rsync
session
shmop
simplexml
snmp
soap
sockets
sourceguardian
spl
spl_types
sqlite3
ssh2
standard
stats
stem
stomp
suhosin
sybase_ct
sysvmsg
sysvsem
sysvshm
tidy
timezonedb
tokenizer
trader
translit
uploadprogress
uri_template
uuid
wddx
weakref
xcache_3
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xrange
xsl
yaf
yaml
yaz
zend_guard_loader
zip
zlib
zmq

PHP 5.6 Extensions

apcu
apm
ares
bcmath
big_int
bitset
brotli
bz2
bz2_filter
calendar
core
ctype
curl
date
dba
dbx
dom
doublemetaphone
eio
enchant
ereg
exif
ffmpeg
fileinfo
filter
ftp
gd
gender
geoip
gettext
gmagick
gmp
gnupg
gRPC
haru
hash
htscanner
http
iconv
igbinary
imagick
imap
inotify
interbase
intl
ioncube_loader
ioncube_loader_4
jsmin
json
ldap
libevent
libsodium
libxml
lzf
mailparse
mbstring
mcrypt
memcache
memcached
mhash
mongo
mongodb
msgpack
mssql
mysql
mysqli
mysqlnd
ncurses
nd_mysql
nd_mysqli
nd_pdo_mysql
oauth
oci8
odbc
opcache
openssl
pcntl
pcre
pdf
pdo
pdo_dblib
pdo_firebird
pdo_mysql
pdo_odbc
pdo_pgsql
pdo_sqlite
pgsql
phalcon
phalcon3
phar
posix
propro
pspell
quickhash
radius
raphf
rar
readline
recode
redis
reflection
rsync
session
shmop
simplexml
snmp
soap
sockets
sourceguardian
spl
spl_types
sqlite3
ssh2
standard
stats
stem
stomp
suhosin
sybase_ct
sysvmsg
sysvsem
sysvshm
tidy
timezonedb
tokenizer
trader
translit
uploadprogress
uri_template
uuid
wddx
weakref
xcache_3
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xrange
xsl
yaml
yaz
zend_guard_loader
zip
zlib
zmq

PHP 7.0 Extensions

apcu
bcmath
bitset
brotli
bz2
calendar
core
ctype
curl
date
dba
dbase
dom
eio
enchant
exif
fileinfo
filter
ftp
gd
gender
geoip
gettext
gmagick
gmp
gnupg
gRPC
hash
htscanner
http
iconv
igbinary
imagick
imap
inotify
interbase
intl
ioncube_loader
json
ldap
libsodium
libxml
lzf
mailparse
mbstring
mcrypt
memcached
mongodb
mysqli
mysqlnd
nd_mysqli
nd_pdo_mysql
newrelic
oauth
oci8
odbc
opcache
openssl
pcntl
pcre
pdf
pdo
pdo_dblib
pdo_firebird
pdo_mysql
pdo_odbc
pdo_pgsql
pdo_sqlite
pdo_sqlsrv
pgsql
phalcon3
phar
posix
propro
pspell
raphf
rar
readline
redis
reflection
session
shmop
simplexml
snmp
soap
sockets
sourceguardian
spl
sqlite3
sqlsrv
ssh2
standard
stats
suhosin
sysvmsg
sysvsem
sysvshm
tidy
timezonedb
tokenizer
trader
uploadprogress
uuid
vips
wddx
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xsl
yaml
yaz
zip
zlib
zmq
  • Please note that to use newrelic extension you should set your own New Relic License Key in your own /opt/alt/php7*/etc/php.ini file. Please find more info about New Relic License Key in the New Relic documentation.

PHP 7.1 Extensions

apcu
bcmath
brotli
bz2
calendar
core
ctype
curl
date
dba
dbase
dom
eio
enchant
exif
fileinfo
filter
ftp
gd
gender
geoip
gettext
gmagick
gmp
gnupg
gRPC
hash
htscanner
http
iconv
igbinary
imagick
imap
inotify
interbase
intl
ioncube_loader
json
ldap
libsodium
libxml
lzf
mailparse
mbstring
mcrypt
memcached
mongodb
mysqli
mysqlnd
nd_mysqli
nd_pdo_mysql
newrelic
oauth
oci8
odbc
opcache
openssl
pcntl
pcre
pdo
pdo_dblib
pdo_firebird
pdo_mysql
pdo_odbc
pdo_pgsql
pdo_sqlite
pdo_sqlsrv
pgsql
phalcon3
phar
posix
propro
pspell
raphf
rar
readline
redis
reflection
session
shmop
simplexml
snmp
soap
sockets
sourceguardian
spl
sqlite3
sqlsrv
ssh2
standard
stats
suhosin
sysvmsg
sysvsem
sysvshm
tidy
timezonedb
tokenizer
trader
uploadprogress
uuid
vips
wddx
xdebug
xml
xmlreader
xmlrpc
xmlwriter
xsl
yaml
zip
zlib
zmq
  • Please note that to use newrelic extension you should set your own New Relic License Key in your own /opt/alt/php7*/etc/php.ini file. Please find more info about New Relic License Key in the New Relic documentation.

PHP 7.2 Extensions

apcu
bcmath
brotli
bz2
calendar
core
ctype
curl
date
dba
dom
eio
enchant
exif
fileinfo
filter
ftp
gd
gender
geoip
gettext
gmagick
gmp
gnupg
gRPC
hash
http
iconv
igbinary
imagick
imap
inotify
interbase
intl
ioncube_loader
json
ldap
libxml
lzf
mailparse
mbstring
memcached
mongodb
mysqli
mysqlnd
nd_mysqli
nd_pdo_mysql
newrelic
oauth
oci8
odbc
opcache
openssl
pcntl
pcre
pdo
pdo_dblib
pdo_firebird
pdo_mysql
pdo_odbc
pdo_pgsql
pdo_sqlite
pdo_sqlsrv
pgsql
phalcon3
phar
posix
propro
pspell
raphf
readline
redis
reflection
session
shmop
simplexml
snmp
soap
sockets
spl
sqlite3
sqlsrv
ssh2
standard
stats
sysvmsg
sysvsem
sysvshm
tidy
timezonedb
tokenizer
trader
uploadprogress
uuid
vips
wddx
xml
xmlreader
xmlrpc
xmlwriter
xsl
yaml
zip
zlib
zmq
  • Please note that to use newrelic extension you should set your own New Relic License Key in your own /opt/alt/php7*/etc/php.ini file. Please find more info about New Relic License Key in the New Relic documentation.

PHP 7.3 Extensions

apcu
bcmath
dba
dbase
dom
eio
enchant
fileinfo
gd
gender
geoip
gmagick
gnupg
grpc
http
igbinary
imagick
imap
inotify
interbase
intl
json
ldap
lzf
mailparse
mbstring
memcached
mongodb
mysqlnd
nd_mysqli
nd_pdo_mysql
newrelic
oauth
oci8
odbc
opcache
pdf
pdo
pdo_dblib
pdo_firebird
pdo_oci
pdo_odbc
pdo_pgsql
pdo_sqlite
pdo_sqlsrv
pgsql
phar
posix
propro
pspell
raphf
redis
snmp
soap
sockets
sqlsrv
ssh2
stats
sysvmsg
sysvsem
sysvshm
tidy
timezonedb
trader
uploadprogress
uuid
vips
wddx
xdebug
xmlreader
xmlrpc
xmlwriter
xsl
yaf
yaml
zip
zmq
  • Please note that to use newrelic extension you should set your own New Relic License Key in your own /opt/alt/php7*/etc/php.ini file. Please find more info about New Relic License Key in the New Relic documentation.

Disabling PHP extension globally

If you want to disable PHP extension globally, you don't need to remove file /opt/alt/phpXX/etc/php.d.all/$EXTENSION.ini . You should just comment out "extension=" directives in it.

The extension will be visible in PHP Selector interface, but selecting it in users's interface will take no effect - extension will be disabled in fact.

Reinstalling of alt-php packages will not reset settings (will not enable extension again).

PHP Selector integration with cPanel’s MultiPHP Manager

Note

Requires CageFS 5.5-6.18+

Overview

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.

The main advantage of 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).

Note

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:

Configuration

Once you’re done with PHP Selector 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.

  1. 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.

  2. 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.

  3. 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 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.

That’s it! You are all set. The only thing that’s left is to make sure that you use the “Enable for all users” mode for CageFS if you’d like to keep PHP Selector for all users.

See also: FAQ on PHP Selector integration with cPanel’s MultiPHP Manager.

More about PHP Selector’s configuration

Setting up the PHP version on customer’s end (in cPanel)

It is possible to change the current PHP Version for MultiPHP Manager on the user’s end. Here’s how the settings would look like by default:

As end-user can change that and select any version, other than Inherited one. Just like with WHM’s MultiPHP Manager, the PHP Selector won’t 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 the PHP Selector is configured properly, its options would have the highest priority. You can find them in cPanel -> Select PHP Version -> Switch to PHP Options.

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 isn’t used

If you haven’t configured the PHP Selector, and you’d 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 it’s already set up). That PHP will also load PHP directives selected in PHP Selector. For example, if we have a setup like this:

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.

/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.