CloudLinux’s PHP Selector allows centralized control over PHP configuration across all users. This guide explains how to edit and apply global PHP settings that affect all cPanel users using alt-php.
📂 File Location
Global PHP settings are controlled via:
/etc/cl.selector/global_php.ini
⚙️ Default Configuration Example
Here’s a secure and performance-optimized configuration:
[Global PHP Settings]
allow_url_fopen = Off
date.timezone = Europe/London
max_execution_time = 600
max_input_time = 300
max_input_vars = 3000
memory_limit = 256M
expose_php = Off
post_max_size = 1024M
session.save_path = /tmp
upload_max_filesize = 1024M
zlib.output_compression = Off
✏️ How to Apply the Changes
1. Edit the Configuration File
Use your preferred text editor:
nano /etc/cl.selector/global_php.ini
Make your changes and save (CTRL + X
, then Y
, then Enter
in nano
).
2. Apply the Changes
CloudLinux provides commands via selectorctl
to apply different types of changes:
Type of Change | Command |
---|---|
General changes (excluding timezone & error_log) | selectorctl --apply-global-php-ini |
All changes including timezone & error_log | selectorctl --apply-global-php-ini --all |
Only date.timezone changes | selectorctl --apply-global-php-ini --timezone |
Only error_log changes | selectorctl --apply-global-php-ini --error-log |
🔒 Security & Performance Recommendations
Setting | Recommended Value | Reason |
---|---|---|
allow_url_fopen | Off | Prevents remote file inclusion vulnerabilities |
expose_php | Off | Hides PHP version from HTTP headers |
memory_limit | 256M or higher | Prevents memory errors in CMS-heavy sites |
session.save_path | /tmp | Ensures reliable session storage |
🧪 Verifying the Changes
Run this command to quickly check if changes applied:
php -i | grep -E "allow_url_fopen|date.timezone|max_execution_time|max_input_vars"
Or, create a phpinfo()
file in public_html
:
<?php phpinfo(); ?>
Then visit the file in your browser to confirm settings.
🔄 Optional: Restart Apache/PHP-FPM
If changes aren’t reflected, restart the relevant services:
/scripts/restartsrv_httpd
/scripts/restartsrv_apache_php_fpm