Xdebug configuration with PHP fastcgi and eclipse?
Asked Answered
T

5

8

I have been using eclipse-pdt in conjunction with xdebug and apache without problems, for over one year. Things worked flawlessly and I could do all the interactive debugging I wanted from within eclipse (using my own machine as a server).

Now I switched from apache to nginx (and therefore PHP runs now not as an Apache service but as fast-cgi) and I can't find a way to configure eclipse to work nicely with xdebug. I am neither sure if the problem is with xdebug or with eclipse (or both) to be sure.

In the eclipse configuration I already changed the reference to the PHP configuration file to /etc/php5/cli/php.ini.


Attempts with php.ini version 1

With the following php.ini file

zend_extension=/usr/lib/php5/20060613/xdebug.so
  • I see that xdebug is working (for example if I do a var_dump() I get the xdebug version of it, not the plain PHP one)
  • I can't have the interactive debugging from eclipse: the browser opens up and loads the page completely with the typical URL containing ...?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=..., but the program execution does not stop at breakpoints
  • In the bottom-right corner of eclipse I see a suspicious message: "Launching =put_the_name_of_my_project_here=: 57%" that alternates with the "refreshing workspace" one.

Attempts with php.ini version 2

If I use this other version of the file (which is what it worked until I switched to nginx):

zend_extension=/usr/lib/php5/20060613/xdebug.so
xdebug.remote_enable=On
xdebug.remote_autostart=On
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_mode=req

I can't access any page of my sites at all.


PS: Additional data on my machine: - OS: GNU/Linux - Ubuntu 9.10 64 bit. - PHP: 5.2.10-2ubuntu6.3 with Suhosin-Patch 0.9.7; Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies with Xdebug v2.0.4 - Eclipse: see screenshot.

alt text

Tyika answered 8/12, 2009 at 17:34 Comment(0)
S
7

What Beau said is correct (couldn't vote since I'm new!).

Generally, addging to /etc/php5/cgi/php.ini (or locate php.ini) the lines like

zend_extension = /PATH_TO/xdebug.so   ## <-- NOTE the absolute path, not relational (For ex on Windows: "C:\nginx-1.9.13\php\ext\php_xdebug-2.6.0RC2-7.0-vc14-nts.dll")
xdebug.remote_enable = on
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remote_port = 9900        ## <-- Yours will be probly 9000 or other..

does the job.

So after the change,

./php-fastcgi stop
./php-fastcgi start

This worked for me.

Stoichiometry answered 23/7, 2010 at 22:57 Comment(2)
Ensure you use zend_extension not the earlier form zend_extension_tsImelda
Your post made me look for what I need to restart.. I had to run /etc/init.d/php5-fpm restartAccuse
I
16

xdebug and FastCGI use the same default port (9000). Change the port of XDebug in your php.ini file like this:

xdebug.remote_port=9001

and update your IDE settings to use 9001.

Imagine answered 25/7, 2011 at 10:45 Comment(3)
THANK YOU! This solved my problem with getting remote debugging working in Netbeans on Windows/IIS7. I was seeing my changes to php.ini from the command line with php -i, but phpinfo() was showing default settings, despite xdebug being enabled. Probably PHP was loading it, but Xdebug was exiting when it found its port in use without making the configuration changes.Raynell
Thanks Effing alot !!! Although i was using my php-fpm and nginx to connect through a socket, changing default port to 9001 solved my issue! I guess php-fpm still occupies the port although its configured to listen to a socket ??Tendinous
Yes! I kept seeing tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 23266/php-fpm: mast and wondered what php-fpm was doing there.Detest
S
7

What Beau said is correct (couldn't vote since I'm new!).

Generally, addging to /etc/php5/cgi/php.ini (or locate php.ini) the lines like

zend_extension = /PATH_TO/xdebug.so   ## <-- NOTE the absolute path, not relational (For ex on Windows: "C:\nginx-1.9.13\php\ext\php_xdebug-2.6.0RC2-7.0-vc14-nts.dll")
xdebug.remote_enable = on
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remote_port = 9900        ## <-- Yours will be probly 9000 or other..

does the job.

So after the change,

./php-fastcgi stop
./php-fastcgi start

This worked for me.

Stoichiometry answered 23/7, 2010 at 22:57 Comment(2)
Ensure you use zend_extension not the earlier form zend_extension_tsImelda
Your post made me look for what I need to restart.. I had to run /etc/init.d/php5-fpm restartAccuse
T
2

Try restarting your php. Because you have php-fastcgi, restarting nginx doesn't seem to do it. When I rebooted my whole server the change took effect.

Tinned answered 14/3, 2010 at 2:3 Comment(1)
Yes php runs as a service, so you can restart it using: sudo service php5-fpm restartSalami
P
1

I had the same problem and solved it.
In file /etc/php5/apache2/php.ini add:

[xdebug] xdebug.remote_enable=On
xdebug.remote_autostart=off
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_mode=req


In file /etc/php5/cli/php.ini add:

zend_extension=/usr/lib/php5/20060613/xdebug.so
xdebug.remote_enable=On
xdebug.remote_autostart=off
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_mode=req


Restart Apache:

sudo service apache2 restart
Puentes answered 15/12, 2009 at 8:51 Comment(3)
@Puentes - I am away from my computer right now, so I can't immediately try... will post later if it worked. However I am a bit puzzled about this solution, as you finish off your instructions with sudo service apache2 restart and I - as specified in the question - do not use apache as a webserver but nginx...Tyika
Srry. In this solution i give example is apache2. But if you can try with other web service :D. When file config was changed must restart web service ( Apache, nginx ..). In solution you set need xdebug.remote_autostart = off. Why set "xdebug.remote_autostart = off". This is answer: if it is "xdebug.remote_autostart = on". This will force Xdebug to start a debug session for every request that is done on this server, without having to specify in the request that a debug session is wanted.Puentes
you can read more here :doc.waterproof.fr/phpedit/debugging_profiling/configuration/…Puentes
P
0

Problem in solution is "xdebug.remote_autostart = on". If you set in file config "xdebug.remote_autostart = on". This will force Xdebug to start a debug session for every request that is done on this server, without having to specify in the request that a debug session is wanted.

You need change

"xdebug.remote_autostart = off"

And restart web service. In this example is Apache.

You can read more here: http://doc.waterproof.fr/phpedit/debugging_profiling/configuration/debugger_with_xdebug

GoodLuck!

Puentes answered 22/12, 2009 at 9:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.