Skip to content
Advertisement

Connection between phpstorm and xdebug

I configured phpstorm-xdebug and I was able to debug my code with breakpoints. These days I updated php (through brew) and xdebug and now I have php 5.5.26 with xdebug 2.3.3. When I try to debug tests (and code) phpstorm tells me: “connection with xdebug was not established”.

I already checked the configuration of xdebug in php.ini and it’s as follow

[xdebug]
zend_extension="/usr/local/opt/php55-xdebug/xdebug.so"
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.remote_port=9000
xdebug.remote_host=127.0.0.1
xdebug.idekey=PHPSTORM

and the web server debug validation says

enter image description here

I tried with different versions of phpstorm, uninstalling e reinstalling php55/php55-xdebug but with no success.

Do you have any idea on how to solve the problem?

Advertisement

Answer

After installing a new PHP, if you start php-fpm without configuring it properly, it defaults to listen on port 9000. Here is the ‘stock’ php-fpm.conf from the distro you need to edit:

/usr/local/etc/php/5.5/php-fpm.conf

...

;   '[::]:port'            - to listen on a TCP socket to all addresses
;                            (IPv6 and IPv4-mapped) on a specific port;
;   '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000

It binds the port 9000, change it to another value (in my case changed it to 8001). Then configure your apache’s config accordingly. Here is my config example config (apache 2.4), binding to port 8001

/usr/local/etc/apache2/2.4/extra/proxy-fcgi.conf

ProxyPassMatch ^/(.*.php(/.*)?)$ fcgi://127.0.0.1:8001/usr/local/var/www/htdocs/$1
DirectoryIndex /index.php

restart apache and php-fpm, and you are good to go to use port 9000 for xdebug. Start PhpStorm.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement