4
votes

I am using a Docker container running PHP 7.1 (php-fpm) and Nginx. I have installed and enabled Xdebug 2.5.0 (as image below shown).

enter image description here

I am trying to debug a single index.php file with this lines of code using "Zero Debug Configuration":

<?php
    phpinfo();

But I am getting the following error:

Cannot accept external Xdebug connection: Cannot evaluate expression '$_SERVER['SERVER_PORT']'

I have search for similar issues and I have found this but nothing there helped me so far.

Here is the PhpStorm configuration related to Debug:

enter image description here enter image description here enter image description here enter image description here enter image description here

I am not sure what is failing here so I need some help around this. The repository with the Dockerfile and so on is here. I am using the following version of PhpStorm:

PhpStorm 2016.3.2 EAP
Build #PS-163.10154.2, built on December 13, 2016
JRE: 1.8.0_112-release-408-b2 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Can any give me some help? What I am missing on this setup?

1
"$_SERVER['SERVER_PORT']" that's a new one -- have not seen port issue before. It's quite possible that your nginx configuration is incomplete (not properly configured). Please check what $_SERVER['SERVER_PORT'] shows in your phpinfo() output (capture it via browser). P.S. Do not touch DBGp Proxy settings if you do not use them. - LazyOne
I'm not a nginx expert (never used it) .. but this line potentially is what causing the issue: github.com/reypm/another-lamp-docker/blob/master/php-fpm/… (EDIT: actually -- not this line .. but the idea is similar -- see next sentence). In any case -- SERVER_PORT variable should be present in $_SERVER and port number should match the one you are using. - LazyOne
@LazyOne I am having another issue and I am not sure what I messed up. At the Dockerfile I am exposing the port 9001 then on the docker-compose.yml I am mapping the port from the container to the host as follow: 9002:9001 then as soon as I try to start a debug session in phpStorm I end up with this error: Can't start listening for connections from 'xdebug': Port 9002 is busy, why? What I miss here? - ReynierPM
Not a Docker user .. but from all the manuals I have read -- you should not expose such ports -- that port IDE will use to listen locally -- it's xdebug that will be connecting to IDE and not other way around. By making it exposed in Docker (so you can connect from Host machine into a container) .. you preventing IDE from listening that port. - LazyOne
@LazyOne you're right I just found this commented out fastcgi_param SERVER_PORT $server_port; and that was causing the issue, it's working now, thanks - ReynierPM

1 Answers

1
votes

This is because you are using unix: socket instead of TCP protocol. Reconfigure PHP-FPM and NGINX to use TCP