[Solved] PHP modules not loading properly – CloudLinux

Problem : The websites using server’s native PHP version is not loading properly. The modules in CloudLinux’s PHP versions are not loading correctly. They are not selected by default.

I faced this problem on one of our servers which has CloudLinux OS with PHP selector. The server has latest cPanel installed and it has EasyApache 4. Its native PHP is set as PHP 5.4 from EasyApache. All websites using this PHP version was throwing the following error on web browsers after enabling mod_lsapi (lsphp).

Unhandled Exception

Message:
Module 'gmp' already loaded 

Location:
Unknown on line 0

Then, I decided to switch the PHP version from server’s native PHP to CloudLinux’s PHP 5.4 version. I tested this on one of the accounts in that server and 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.

Why it’s not taking the added modules by default? What’s the solutions?

This problem can be fixed by using cagefsctl command. Here I found the following workaround:

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.” See the image for more details:

cloudlinux

See the section “Default PHP version

Step 2 : Now you need 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 particular particular user, please execute the above command with corresponding username:

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

That’s it!

Step 3 : Now, it’s time that we 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 you need to change the PHP version of users which are using native version.

You can use the following command:

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

Or use the following for loop:

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."; done

That’s it!!

Now check the modules via cPanel. Everything should be alright!!

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

Leave a Reply

Your email address will not be published. Required fields are marked *