How to install xdebug for lsphp — CyberPanel - WebHosting Control Panel for OpenLiteSpeed
CyberHosting

How to install xdebug for lsphp

edited February 8 in Tutorials
I was reviewing setting up xdebug for phpstorm recently and stumbled on some posts which while helpful were not entirely complete.

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

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; 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; systemctl restart lsws||service lsws restart; systemctl status lsws||service lsws status;


Should look like this
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:

[[email protected]:~]# 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

PHP lsphp80
-bash: /usr/local/lsws/lsphp80/bin/php: No such file or directory
[[email protected]:~]#


Hopefully this is helpful for anyone else looking to setup their IDE and remote debugging.
Tagged:
Tagged:
Sign In or Register to comment.
CyberPanel Discord

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!