Wondering how to enable PHP Function in cPanel Server with EasyApache4? We can help you.
As part of our Server Management Services, we assist our customers with similar queries.
Today, let us see how our Support techs resolve this.
How to enable PHP Function in cPanel Server with EasyApache4?
Sometimes, we might want to have a single account with a different php.ini.
CloudLinux allows to set individual PHP functions in the users php.ini file.
Substitute global php.ini for individual customer
To do that, we can use custom.etc directory functionality.
Today, let us see the steps followed by our Support Techs to do it.
1. Firstly, 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
2. Then, change path to php.ini in /etc/cl.selector/native.conf file to:
php.ini=/etc/php.ini
3. For each user that needs custom file, create directory /etc/cagefs/custom.etc/USER_NAME/php.ini.
For example, to create custom for USER1 and USER2, create the files:
/etc/cagefs/custom.etc/USER1/php.ini
/etc/cagefs/custom.etc/USER2/php.ini
4. Finally, create such files for each user that should have custom file.
Execute:
$ cagefsctl –force-update
- Make sure that php.ini load path is set to /etc/php.ini.
- Users will be able to override settings of those php.ini files (global or custom) via PHP Selector.
If we want to prevent that, we should disable PHP Selector feature.
- 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.
- If we modify anything in /etc/cagefs/custom.etc directory, we 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.
Substitute global php.ini for individual customer on cPanel server with EasyApache4
Recommended ways to manage php.ini settings per user are to use cPanel MultiPHP or CloudLinux OS Shared PHP Selector interfaces.
How to use cPanel MultiPHP or CloudLinux OS Shared PHP Selector interfaces?
1. For each user that needs custom file, create directory /etc/cagefs/custom.etc/USER_NAME/php.ini.
For example, if we want to create a custom file for USER1 and USER2, we 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. Then, execute the following command:
$ cagefsctl –force-update
3. Finally, configure php.ini load path for user’s domains.
- We should restart Apache web server after modifying virtual host configuration for the domains.
- Custom php.ini may break switching PHP version via CloudLinux OS Shared PHP Selector or cPanel MultiPHP Manager for the appropriate users or domains.
- When using cPanel ea-php for the domains, additional php.ini files may not be loaded, so we should load all needed PHP extensions in custom /etc/php.ini file.
- When using CloudLinux OS Shared alt-php, additional php.ini files will be loaded.
- If we modify anything in /etc/cagefs/custom.etc directory, we 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
[Stuck in between? We are glad to assist you]
Conclusion
In short, today we saw steps followed by our Support Techs to enable PHP Function in cPanel Server with EasyApache4.
0 Comments