简体   繁体   中英

PHP debug environment not working

I am at the end of my tail here and could really use some help!

Here's my setup -

  • NGINX, PHP-FPM on CentOS
  • Nginx conf file has the following:

    location ~ .php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }

  • PHP-FPM conf file at /etc/php-fpm.d/www.conf has the following listen=127.0.0.1:9000

With the above configuration, NGINX can properly display PHP pages.

Now, I want to setup Xdebug. So I added the following to the /etc/php.d/xdebug.ini file

<code>
zend_extension=/usr/lib64/php/modules/xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=x.x.x.x
xdebug.remote_port=9009
xdebug.remote_autostart=1
</code>

Note remote port is set to 9009 to not conflict with the PHP-FPM port 9000.

On the xxxx machine, I have XDebugClient running listening for incoming connections on port 9009.

Next, I launch a browser from the host xxxx and request URL http://yyyy?XDEBUG_SESSION_START=1 (where yyyy) is the server with the NGINX, PHP-FPM and XDebug setup.

The issue - nothing happens. XDebugClient never gets a connection!

What am I missing?

Things to check

  • Pull up a phpinfo() page to make sure your php.ini file is configured correctly. If you don't see a long xdebug section, then the problem is in your configuration.
  • Try running a trace or profile with xdebug. If they work, then the xdebug module itself is okay.
  • Try setting xdebug.remote_connect_back=1 in your php.ini file. This will override the remote_host setting and can be helpful if the problem is related to network configuration.
  • Make sure your IDE is set to listen for the connection on port 9009. In PHPStorm, for example, you must configure the IDE to listen on the custom port, and then you have to push a button to activate the debugging tool before you load the page being debugged.

Those are the basic steps I've had to go through quite a few times. Hopefully one of them will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM