PHP serves as the backbone of most dynamic websites and applications. To keep your site secure, compatible, and performant, it is essential to manage the versions, extensions, and configurations of PHP on your cPanel-based server. cPanel (for users) and WHM (for administrators) both offer tools that make it easy to manage PHP through EasyApache 4 and MultiPHP Manager.
This provides a complete overview of managing PHP in cPanel and WHM, including how to choose a PHP version, how to disable PHP extensions, and how to configure PHP.
1. PHP in cPanel: An Overview
Today, cPanel servers utilize EasyApache 4 to control PHP environments. With EasyApache 4, you have greater flexibility in supporting multiple PHP versions at the same time without conflicts, so you can accommodate different website needs.
- Users can choose their preferred PHP version by domain or account.
- Administrators can enable specific PHP versions and extensions on a global level.
This means older applications can continue to run on older PHP versions, while newer websites have access to licensed and secure versions.
2. Checking Installed PHP Versions
Before making any changes, it’s important to verify the PHP versions currently installed on your server. This can be done directly through the WHM interface.
- Navigate to:
WHM – EasyApache 4
Here, you can view all installed PHP versions, such as 7.4, 8.0, or 8.1, and install or remove versions as needed.
- You can also check the default system PHP version from the command line:
php -v
This displays the active PHP version used by the system for CLI operations.
3. Changing PHP Version for a Domain
Different websites on the same server may require specific PHP versions due to compatibility factors. For example, older applications may not support the latest syntax or libraries.
To change the PHP version for a domain:
- Log in to cPanel.
- Go to Select PHP Version.
- Choose the desired PHP version (e.g., 8.1).
- Click Set as Current.
This change applies only to the selected domain, ensuring independent PHP management for each hosted website.
4. Enabling or Disabling PHP Extensions
PHP extensions enhance functionality by adding support for various modules such as MySQLi, gd, or curl. Users can easily control these modules within cPanel.
Steps:
- In cPanel, navigate to Select PHP Version.
- Check or uncheck the desired extensions.
- Click Save Changes.
This method allows users to customize PHP based on their application’s needs—whether it’s image processing, database connectivity, or API interaction.
5. Managing PHP Versions Using MultiPHP Manager (WHM)
From the WHM side, administrators can manage PHP settings for all domains using the MultiPHP Manager tool.
- Navigate to:
WHM – MultiPHP Manager
Here you can:
- Assign different PHP versions to individual domains or cPanel accounts.
- Define a system wide default PHP version.
This feature is particularly beneficial for web hosting environments that manage multiple clients, each requiring different PHP configurations.
6. Changing PHP Settings (php.ini Values)
Beyond version and extensions, PHP performance is influenced by its configuration parameters. These are defined in the php.ini file. cPanel provides a convenient interface for adjusting common settings.
In cPanel:
- Go to Select PHP Version – Options.
- Modify parameters such as:
- memory_limit (e.g., 256M)
- upload_max_filesize (e.g., 128M)
- post_max_size (e.g., 128M)
- max_execution_time (e.g., 300)
- For more advanced control, administrators can edit the php.ini file directly via CLI:
/opt/cpanel/ea-php81/root/etc/php.ini
- After making changes, restart Apache to apply them:
systemctl restart httpd
These configurations ensure that PHP runs optimally, particularly for resource-intensive websites and applications.
7. Common PHP Management Issues
Even with proper configuration, a few common issues can occur during PHP management:
- Website shows a blank page:
This usually indicates a fatal error. Enable PHP error reporting or check the Apache error log at:
/usr/local/apache/logs/error_log - PHP version not updating:
Verify settings in MultiPHP Manager within WHM. Sometimes the domain may still inherit a global PHP configuration. - Missing PHP extensions:
Use EasyApache 4 to install the required extensions and reapply them through cPanel.
Proactively checking logs and confirming PHP configurations can resolve most of these issues quickly.
Efficient handling of PHP in cPanel/WHM is essential in order to optimize security, performance, and compatibility with website data. Administrators and users can easily manage PHP versions, extensions, and settings per domain by using EasyApache 4 and MultiPHP Manager.
ServerAdminz provides management services that include controlling PHP versions, tuning performance, and applying updates to enhance security. Our professional team is available to make sure your server environment provides consistent performance for legacy and modern applications alike. ServerAdminz provides real-time monitoring and technical support that keeps your web operations uninterrupted.
