This guide will walk you through the steps of enabling Xdebug for PHP in WHM.
Xdebug is a powerful PHP extension used for debugging and profiling. To enable it in a WHM environment, follow these steps:
- Install Xdebug via PECL (Recommended)
- Log in to WHM as root.
- Select the “Software” option and click on the “Module Installers” sub-option.

- Click “Manage” next to PECL.

- Select the PHP version (e.g., ea-php72 or higher) and click “Apply.”

- Enter “xdebug” in the install field and click “Install Now.”

- Modify the php.ini File to Enable Xdebug
To configure Xdebug, you will need to update the “php.ini” file associated with your PHP version. Follow these steps:- Identify the Active Configuration File:
Create a simple PHP file with <?php phpinfo(); ?>, open it in a browser, and look for the line labelled Loaded Configuration File. This shows the exact php.ini path in use. - Open php.ini and make the Following Changes:
- Deactivate Zend Debugger: If any Zend debugger or optimiser lines are present, disable them by commenting them out (prefix the line with a semicolon ;).
- Insert the Xdebug Configuration Block
- For Xdebug 3:
[xdebug] zend_extension=“/full/path/to/xdebug.so” xdebug.mode=debug xdebug.client_host=127.0.0.1 xdebug.client_port=9003
- For Xdebug 2:
[xdebug] zend_extension=“/full/path/to/xdebug.so” xdebug.remote_enable=1 xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000
- Optional: Add implicit_flush = On if required for your environment.
- For Xdebug 3:
- Save the Configuration File and restart the relevant services to apply the changes:
/scripts/restartsrv_httpd /scripts/restartsrv_apache_php_fpm
- Identify the Active Configuration File:
- Confirm Xdebug Is Active
After restarting, open your “phpinfo()” file again. If Xdebug was successfully configured, you will see a dedicated section for it with all relevant directives. - Configure Your IDE for Debugging:
- Set your development environment (e.g., PhpStorm) to listen for Xdebug connections on the correct port (9000 for Xdebug 2, 9003 for Xdebug 3).
- Map project directories between your local machine and the server to ensure proper breakpoint functionality.
- Consider installing browser extensions like Xdebug Helper to simplify starting debug sessions from the browser.
Once enabled using these steps, Xdebug will be ready for use in your WHM-based PHP development and debugging setup.
Want to install Xdebug manually? Learn How to install Xdebug using CMD