Target Stack: CloudLinux 9.5 + cPanel 126
CloudLinuxβs PHP Selector allows fine-grained control of PHP modules per user or server-wide via selectorctl
. This is essential for shared hosting environments where different applications require different PHP setups.
π Prerequisites
Before managing PHP modules:
- β Root access to the server
- β CloudLinux PHP Selector installed
- β CageFS enabled and configured for users
- β
Relevant PHP versions and modules installed via
alt-php
π Module Management Per User
To enable specific PHP extensions for a single cPanel user, use:
selectorctl --enable-user-extensions=mysql,mysqli --version=5.6 --user=exampleuser
selectorctl --enable-user-extensions=json --version=5.6 --user=exampleuser
π Explanation:
--enable-user-extensions=
: Comma-separated list of extensions--version=
: Target alt-PHP version (e.g., 5.6, 7.4, 8.1)--user=
: cPanel username (replaceexampleuser
accordingly)
π Enable Modules Globally (All Users)
To apply PHP modules globally for all users using PHP 5.6:
selectorctl --enable-extensions=apcu,bcmath,dom,fileinfo,gd,imagick,imap,ioncube_loader,json,mbstring,mcrypt,memcache,mysql,mysqli,mysqlnd,opcache,pdf,pdo,pdo_mysql,phar,posix,pspell,redis,soap,sockets,suhosin,tidy,xmlreader,xmlwriter,xsl,zend_guard_loader,zip --version=5.6
To verify the available PHP extensions for a version:
selectorctl --list-extensions --version=5.6
π Reset All User Modules to Match Global Settings
To reset all usersβ PHP modules to match the global defaults:
cagefsctl --cl-selector-reset-modules
This is useful after major global configuration changes.
β Final Steps
Always run the following after modifying PHP Selector settings:
cagefsctl --force-update
Optionally restart your web service (depending on your setup):
systemctl restart httpd # For Apache
systemctl restart lsws # For LiteSpeed
π§ͺ Test Module Availability
Create a simple PHP info file in the userβs public_html
directory to verify the loaded modules:
<?php phpinfo(); ?>
Visit https://domain.com/phpinfo.php
and check the Loaded Extensions section.