Install xdebug in centos7 with php7

Install xdebug in centos7 with php7

I just realised I dont have a post on how to install xdebug in centos7 with php7 and setting up xdebug and eclipse. Its a feature that I use every day, and I had assumed I already had a post, but when searching my site ) only found instructions for XAMPP and xdebug.
I’m assuming you already have apache / php installed and working, and that you only need to add xdebug. This post shows how to install xdebug in centos7 with php7.
If you dont alreay have php7 installed in your centos7, you can follow my other post here. Once you have php7 installed, you can then install xdebug with the following:

Install xdebug in centos7 with php7

if you have php7 in centos7 with webtactic and epel you can install xdebug with the following


yum install php70w-pecl-xdebug.x86_64

if you have epel and webtactic, but not php7 you can install xdebug with:


yum install php-xdebug

Now that xdebug is in your sytstem its time to confgure xdebug

  • open /etc/php.d/xdebug.ini in your favourite editor
  • add the following lines

	#this line will be added automatically
        zend_extension = /usr/local/lib/php/extensions/xxx/xdebug.so
        #add the following
	xdebug.remote_log="/tmp/xdebug.log"
	xdebug.profiler_enable = 1
	xdebug.remote_enable=on
	xdebug.remote_port=9000
	xdebug.remote_autostart=0
	xdebug.remote_connect_back=on
	xdebug.idekey=editor-xdebug

You can find the correct paths to the files needed if you have yum-utils installed and run


	repoquery --list  php70w-pecl-xdebug
	
	# the output is:
	/etc/php-zts.d/xdebug.ini
	/etc/php.d/xdebug.ini
	/usr/bin/debugclient
	/usr/lib64/php-zts/modules/xdebug.so
	/usr/lib64/php/modules/xdebug.so
	/usr/share/doc/php70w-pecl-xdebug-2.4.1
	/usr/share/doc/php70w-pecl-xdebug-2.4.1/CREDITS
	/usr/share/doc/php70w-pecl-xdebug-2.4.1/LICENSE
	/usr/share/doc/php70w-pecl-xdebug-2.4.1/README.rst
	/var/lib/pear/pkgxml/xdebug.xml

You now need to restart httpd


service httpd restart
# or
systemctl restart  httpd.service

Xdebug will now be up and running

Eclipse

Inside eclipse, goto preferences > php > debuggers
change the debugger to xdebug
click configure
change the dropdown for “accept remote session (JIT)” to “any” or “prompt”
click ok

Firefox

Easy Xdebug is the best solution I have found for firefox – simply install the extension from here, navigate to the site you want to debug, and click the little green bug to open in your editors debugger. you might need to add the key you added to your xdebug.ini in the previous steps.

sources:
https://www.jetbrains.com/help/phpstorm/2016.2/configuring-xdebug.html#updatingPhpIni
https://xdebug.org/docs/install