How to install Xdebug for lsphp

This tutorial shows how to install Xdebug for lsphp for Litespeed/Openlitespeed servers for control panels like Cyberpanel.

Installation via pecl is easiest so first step is ensuring pecl is updated.

Update pecl

for version in $(ls /usr/local/lsws|grep lsphp); do /usr/local/lsws/${version}/bin/pecl channel-update pecl.php.net; done

Install via pecl for Centos

Extension="xdebug";for version in $(ls /usr/local/lsws|grep lsphp); do php_ini="/usr/local/lsws/${version}/etc/php.d/zzzzzzz-pecl.ini"; printf '\n' |/usr/local/lsws/${version}/bin/pecl install ${Extension} && echo "zend_extension=${Extension}.so" >> ${php_ini}; echo "xdebug.mode=debug" >> ${php_ini}; echo "xdebug.remote_enable=1" >> ${php_ini}; echo "xdebug.remote_connect_back=1" >> ${php_ini}; echo "xdebug.remote_port=9000" >> ${php_ini}; echo "xdebug.client_port=9000" >> ${php_ini}; done; killall lsphp ; systemctl restart lsws||service lsws restart; systemctl status lsws||service lsws status;

Install via pecl Ubuntu

Extension="xdebug";for phpver in $(ls -1 /usr/local/lsws/ |grep lsphp | sed 's/lsphp//g'); do php_ini="/usr/local/lsws/lsphp${phpver}/etc/php/$(echo $phpver | sed 's/^(.{1})/\1./')/litespeed/php.ini"; printf '\n' |/usr/local/lsws/lsphp${phpver}/bin/pecl install ${Extension} && echo "zend_extension=${Extension}.so" >> ${php_ini}; echo "xdebug.mode=debug" >> ${php_ini}; echo "xdebug.remote_enable=1" >> ${php_ini}; echo "xdebug.remote_connect_back=1" >> ${php_ini}; echo "xdebug.remote_port=9000" >> ${php_ini}; echo "xdebug.client_port=9000" >> ${php_ini}; done; killall lsphp ; systemctl restart lsws||service lsws restart; systemctl status lsws||service lsws status;
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.client_port=9000
xdebug.client_host=YOURIP

Check if its installed

for version in $(ls /usr/local/lsws|grep lsphp); do echo ""; echo "PHP $version"; /usr/local/lsws/${version}/bin/php -v; done

Example:

[root@wcloud:~]# for version in $(ls /usr/local/lsws|grep lsphp); do echo ""; echo "PHP $version"; /usr/local/lsws/${version}/bin/php -v; done

PHP lsphp70
PHP 7.0.33 (cli) (built: Nov 22 2019 11:16:42) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with the ionCube PHP Loader + ionCube24 v10.3.9, Copyright (c) 2002-2019, by ionCube Ltd.
    with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies

PHP lsphp71
PHP 7.1.33 (cli) (built: Nov 22 2019 11:40:51) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with the ionCube PHP Loader + ionCube24 v10.3.9, Copyright (c) 2002-2019, by ionCube Ltd.
    with Zend OPcache v7.1.33, Copyright (c) 1999-2018, by Zend Technologies

PHP lsphp72
PHP 7.2.34 (cli) (built: Oct  1 2020 17:07:20) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with the ionCube PHP Loader + ionCube24 v10.3.9, Copyright (c) 2002-2019, by ionCube Ltd.
    with Zend OPcache v7.2.34, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans

PHP lsphp73
PHP 7.3.26 (cli) (built: Jan  7 2021 09:22:23) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.26, Copyright (c) 1998-2018 Zend Technologies
    with the ionCube PHP Loader + ionCube24 v10.3.9, Copyright (c) 2002-2019, by ionCube Ltd.
    with Zend OPcache v7.3.26, Copyright (c) 1999-2018, by Zend Technologies
    with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans

PHP lsphp74
PHP 7.4.14 (cli) (built: Jan  7 2021 08:53:32) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with the ionCube PHP Loader + ionCube24 v10.4.4, Copyright (c) 2002-2020, by ionCube Ltd.
    with Zend OPcache v7.4.14, Copyright (c), by Zend Technologies
    with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans

[root@wcloud:~]#

Hopefully this is helpful for anyone else looking to setup their IDE and remote debugging.

Other helpful resources:

https://xdebug.org/docs/install#pecl
https://forum.openlitespeed.org/threads/php-xdebug.2397/

Leave a Comment

Item added to cart.
0 items - $0.00