PHP modules not loading properly on CloudLinux

We were facing this problem on one of our server, Those websites using server’s native PHP version were not loading properly. The modules in CloudLinux’s PHP versions are not loading correctly. They are not selected by default. Our server has latest cPanel installed with EasyApache 4 .

All websites using this PHP version was giving the following error on web browsers after enabling mod_lsapi (lsphp).

Unhandled Exception
Module 'gmp' already loaded
Unknown on line 0

When, I try to switch the PHP version from server’s native PHP to CloudLinux’s PHP 5.4 version, that did the trick. But, this time, I got some other errors (Modules missing alert) on web browser. I was able to fix those errors by enabling those modules from PHP selector.

Now question is this Why it’s not taking the added modules by default?

This issue can be fixed by using cagefsctl command. Follow the steps below:

Step 1 : Loged into WHM as root and change the PHP version from server’s native 5.4 to CloudLinux 5.4

You can change this from “CloudLinux LVE Manager.”


Step 2 : Now you have to execute the following command to enable added modules (by default modules):

# cagefsctl --cl-selector-reset-modules

This command will reset modules for all users to its default.
To change this for a specific user, please execute the above command with corresponding username:

# cagefsctl --cl-selector-reset-modules $user1 $user2

Step 3 : Now, to switched all account’s PHP versions from native PHP to ClodLinux’s PHP 5.4.

You can use the “selectorctl” command to change the PHP version of an account via command line. First, we need to know which accounts are using server’s native default PHP. Execute the following command:

# selectorctl --list-users --version=native

Now to change the PHP version of users which are using native version. Use the following command:

# selectorctl --change-to-version=5.4 --version=native

Or use the following :

for user in `selectorctl --list-users --version=native | 
sed 's/,/ /g'`; do echo -n "Changing PHP version of $user to 5.4: ..... 
" && selectorctl --set-user-current=5.4 --user=$user && echo "Okay."; 

That’s all  you have to do, Now if you check the modules via cPanel, Everything should be alright!!.  You also like to know How To Setup A Working Apache Server On Ubuntu 16.04Please check my previous article on this and also give your opinion below if you experience any issues or to discuss your ideas and experiences.