How to Enable Xdebug for PHP in WHM

July 22, 2025 / cPanel & WHM

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:

  1. Install Xdebug via PECL (Recommended)
    1. Log in to WHM as root.
    2. Select the “Software” option and click on the “Module Installers” sub-option.
      software>module installers
    3. Click “Manage” next to PECL.
      PHP PECL
    4. Select the PHP version (e.g., ea-php72 or higher) and click “Apply.”
      apply
    5. Enter “xdebug” in the install field and click “Install Now.”
      install now
  2. 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:

    1. 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.
    2. Open php.ini and make the Following Changes:
      1. Deactivate Zend Debugger: If any Zend debugger or optimiser lines are present, disable them by commenting them out (prefix the line with a semicolon ;).
      2. 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.
      3. Save the Configuration File and restart the relevant services to apply the changes:
        /scripts/restartsrv_httpd
        /scripts/restartsrv_apache_php_fpm
  3. 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.
  4. Configure Your IDE for Debugging:
    1. Set your development environment (e.g., PhpStorm) to listen for Xdebug connections on the correct port (9000 for Xdebug 2, 9003 for Xdebug 3).
    2. Map project directories between your local machine and the server to ensure proper breakpoint functionality.
    3. 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

Spread the love