🛠️ How to Manage Global PHP Settings in cPanel on CloudLinux 9.5

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 ChangeCommand
General changes (excluding timezone & error_log)selectorctl --apply-global-php-ini
All changes including timezone & error_logselectorctl --apply-global-php-ini --all
Only date.timezone changesselectorctl --apply-global-php-ini --timezone
Only error_log changesselectorctl --apply-global-php-ini --error-log

🔒 Security & Performance Recommendations

SettingRecommended ValueReason
allow_url_fopenOffPrevents remote file inclusion vulnerabilities
expose_phpOffHides PHP version from HTTP headers
memory_limit256M or higherPrevents memory errors in CMS-heavy sites
session.save_path/tmpEnsures 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
Scroll to Top