I want to debug remote server (AWS EC2 Ubuntu), where there is a PHP application. I use PhpStorm locally on my Windows machine. I can not debug the app on the server.
I have Googled a lot and found a lot of explanations, but stuck. I have installed Xdebug on the server and locally. I have setup the SFTP connection in PhpStorm, so it has the Server and can synchronize. The PhpStorm->Settings->Languages & Frameworks->PHP->Debug - [Validate] says everything is OK, when I choose Remote Web Server
When I click Start listening for PHP Debug connections in the PhpStorm IDE, I can debug the PHP code with breakpoints. The files are exactly the same as on my server. But nothing happens right now.
First and foremost; xdebug should be able to call back home; ie the local computer running phpStorm.
Here is a quick checklist
can the remote connect to local directly? Can the remote host connect to local hosts xdebug port (generally 9000)?
IF yes;
is xdebug configuration correct? Here is an example for a direct connection between remote and local:
xdebug.remote_enable = 1
xdebug.remote_port = 900
xdebug.remote_connect_back = On
IF No;
there should be a way for remote to connect back to local. One option would be using an ssh tunnel. For that; xdebug configuration on remote should be amended accordingly; like:
xdebug.remote_host=127.0.0.1
xdebug.remote_port = 9001
xdebug now tries to connect its own port; 9001 which is actually a tunnel to your localhost; port 9000
you can create a tunnel with ssh on nix; Putty on win
Also, xdebug log files are indispensible whide debugging problems; be sure that xdebug IS creating logs; check them; example:
xdebug.remote_log = /var/tmp/xdebug.log
After all those are set; activate PHPStorm's listening mode and start debugging.
Also; may be good to remember the documentation
Related
I'm trying to debug my dev environment which is in a different network from my localhost with PhpStorm and Xdebug. I tried many things but couldn't find the fix.
Below is my php.ini file settings:
zend_extension="/usr/lib/php5/20121212/xdebug.so"
xdebug.remote_host=192.168.0.101
xdebug.remote_connect_back=1
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.idekey="XDEBUG_ECLIPSE"
xdebug.remote_log="/tmp/xdebug.log"
xdebug.remote_handler=dbgp
As my dev server and debugging environment is different, I have provided my local system IP address.
Xdebug logs give below error:
I: Checking remote connect back address.
I: Remote address found, connecting to 192.168.1.1:9000.
E: Could not connect to client. :-(
Is this issue coming because my local and dev server belongs to different network?
Try to connect from your host machine to PHPSTORM
nc -vz 192.168.1.1 9000
If success try the same from dev
If it fails from dev the yes its because dev machine in other network
I want to do PhpStorm remote debug setting in cloud server which installed nginx with SSL.
For that I did add parameter in php.ini like following:
zend_extension = /usr/lib//xdebug.so
xdebug.remote_enable=1
;xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_log="/tmp/xdebug.log"
xdebug.idekey="PHPSTORM"
xdebug.remote_mode="req"
xdebug.remote_handler="dbgp"
xdebug.remote_autostart=1
xdebug.remote_connect_back =1
and I modify the cloud server as follow
using ufw, the 80, 443, 9000 port opened
I set up my PhpStorm:
1. php web server setting
host : test.com (example)
port : 80/443 (I did test it, but didn't work all two case)
mappings : add local files info and hosting path in absolute path
2. remote debug
select server info (test.com)
ide key : PHPSTORM
after that I installed xdebug helper in the Chrome browser; changed the IDEKEY to be PHPSTORM.
I have downloaded the full source using SFTP from the server, it doesn't need setting up synchronization.
Using above setting I couldn't get a result.
So, I might think, the reason of failure is the SSL environment. But that was just my guess.
If you have been like this case, please give me the tip and example.
PhpStorm web manual is so simple to understand and solve my problem. Please don't leave me PhpStorm web manual links.
I'm trying to use XDebug in the following scenario
my computer Windows 7, Netbeans 6.9
Physical Host at computer on the same network (Windows 7) with virtual Box
Virtual CentOS 6.2, with Apache server 2.2.15 and PHP 5.3.3
the PHP code of my website is on a shared folder on CentOS, in /var/www/html/mysite and have separate and can access it by server ip 192.168.1.240
Edited C:\Windows\System32\drivers\etc\hosts 192.168.1.240 mysite
the PHP code is accessible from my Windows host, on \\HostIP\html\mysite, with R/W permissions
I created a Netbeans project on my computer, pointing to \\HostIP\html\mysite. In the project Run configuration, I have the following:
Run as: Remote Web Site
Project URL: http://mysite/
Index file: index.php (does exist in the project)
In the Advanced Run Configuration:
I checked "Default"
I haven't touched the proxy settings
I have the following in the php.ini on my CentOS VM
;extension=xdebug.so
zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_log="/var/log/xdebug.log"
;xdebug.remote_host=192.168.1.31
xdebug.remote_connect_back=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
note: I tried the configurations with extension=xdebug.so and tried commenting xdebug.remote_connect_back=1 with uncomment xdebug.remote_host=192.168.1.31 which is my computer ip address.
so basically i have all the configurations like this image
but still not working! after run the debugger will open this url
http://mysite/index.php?XDEBUG_SESSION_START=netbeans-xdebug
and nothing will happened just netbeans Listing waiting for Xdebug connection
When i want to debug on a remote host i normally have to forward my local 9000 port to the remote server's local 9000 via a ssh tunnel:
ssh -R 9000:localhost:9000 username#remote.example.com
Use bitvise ssh client or putty on windows to get the same effect.
Also in the project settings -> run configuration -> Advanced button
make sure to specify the remote and local full paths the the project files so the debugger can attach (don't worry about the port in this screen leave as standard).
I know this is an old post, but it seemed like the one I ran across the most tonight.
The NAT Network setup is the way to get the least amount of conflict. In the Windows 7 Firewall, setup a custom Inbound Rule to allow inbound traffic to port 9000 for the entire /24 network that the VM is on (192.168.202/24).
My working XDebug setup in the php.ini, using 2.2.7 with Netbeans 8.0.2:
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.idekey="netbeans-xdebug"
xdebug.show_local_vars=0
;xdebug.extended_info=1
xdebug.output_buffering=off
xdebug.remote_log=/var/log/xdebug.log
Lastly, I want to point out that Netbeans listens for the remote address setup in the remote file config. Doing a quick netstat -an showed that Netbeans was listening on port 9000, with a CLOSE_WAIT status on an old address from my initial bridged network setup. Even after changing the Project URL, and the Remote Connection IP address, and closing several xdebug connections, this never changed. Only after closing Netbeans, does the stale connection drop. Once Netbeans is started again, the new remote server URL is used for the remote xdebug connection.
Mention of Netbeans holding a stale state was never discussed, and the ability to stop the xdebug connection from the IDE gives a false sense of resetting the socket.
If it still doesn't work, use the provided debugclient on the VM, visit the project page with "?XDEBUG_SESSION_START=netbeans-xdebug" appended to the index.php URL, and watch for the xdebug info to come in. At least then you know it works locally.
Try setting up any breakpoint to your executed script. Debug session may not show up while ide does not respect "break at first line" flag.
Also check if xdebug.idekey property in php.ini equals to ideKey in Netbeans' settings.
I am trying to get Xdebug remote debugging to work, I am using PHPStorm as my IDE.
My webserver/code is hosted on a remote machine (amazon ec2).
I have the following lines in my php.ini on my remote server (PHP CLI since I am doing PHPUnit debugging)
zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
Since I am programming from my home network, I opened port 9000 on my personal router.
I have PHPStorm's xdebug server set to point to the remote server on port 80 with Xdebug as it's Debugger.
Now when I try to debug a PHPUnit test from PHPStorm it just says
'waiting for incoming connections with ide key '12115'
Except, it picks a random ide key every single time (I want to hope that PHPUnit is setting the idekey on the server itself)
I have been trying to get this to work for over 10 hours, I have tried defining my a specific remote_host in the php.ini instead of using remote_connect_back but that also did not work. I have tried setting an idekey in php.ini and that did not work as well.
Is there anyway to confirm that Xdebug is working as intended on the webserver side? How can I test my Xdebug settings without using Phpstorm, I don't know if it is a connection issue between my home network and the remote server or what.
Any guidance to help narrow down the issue would be great.
I know that the question is a little old, but since I had the same problem and just found a solution, I have decided to post here for anyone interested.
My solution is heavily based on the one provided by Rafael Dohms in
his blog post entitled: Debugging PHPUnit Tests in NetBeans with
XDebug
Environment
IDE: PHPStorm 6.0.2
Server: WAMP Server (32-bit & PHP 5.4.3) 2.2E
XDebug: 2.2.2
XDebug
zend_extension=c:\wamp\bin\php\php5.4.3\ext\php_xdebug-2.2.2-5.4-vc9.dll
xdebug.extended_info=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_log=c:/wamp/tmp/xdebug/xdebug_remote.log
The above configuration parameters go into the "php.ini" file for CLI. For the default WAMP installation, the full path to this file is: C:\wamp\bin\php\php5.4.3\php.ini
PHPStorm
First of all, you must create a "Server Configuration" (google "Creating a Server Configuration - JetBrains" for the official doc on the subject) specifying "Xdebug" as the "Debugger".
Then, create a new "PHP Remote Debug Configuration" (google "Creating and Editing Run/Debug Configurations - JetBrains" for the official doc on the subject) specifying the following values under the "Configuration" section:
Servers: the server created above
Ide key: PHPSTORM
Now, select that configuration and press the "Debug" button (or "Shift + F9"). PHPStorm will display the "Debug" panel and show the message: Waiting for incoming connection with ide key 'PHPSTORM'
Finally, "run" you PHPUnit test. There are several ways. One of them is:
Right click the name of the file the PHPUnit test resides in.
Select "Run file name"
That's it! XDebug will take control from here on.
If you're running Xdebug 2.2.0RC1, then the remote debug-log (http://xdebug.org/docs/all_settings#remote_log) will tell you succeeded and failed connection attempts. That might pinpoint whether the problem is on the Xdebug side, or phpstorm side.
In my case, the problem was that I had the xdebug config in /etc/php/fpm/php.ini, but php-cli uses /etc/php/cli/php.ini.
Since it took me a day to get it to work, I will sum up, what in learned:
Make sure, you are changing the right php.ini, XAMPP uses another php.ini and php version, than the one preinstalled on OS X Mavericks.
Define a logfile and if nothing is written into it, you a changing the wrong php.ini
In phpstorm you can validate your server connection and gain insight, if you are working on the right php.ini or what is still wrong.
You have to change settings for debug (might be worth to change the port to 9001), the server, all in phpstorm preferences and set up.
You have to set the php language level and the Interpreter (use the one your Apache mysql php configuration uses) e.g. /Application/XAMPP/xamppfiles/bin, click on ... to see Php and if debugger is attached. You might have to use another version of xdebug.
In Servers you have to define Host as
http://yourdefinitionofprojectonlocalhost
with usually Port 80 and Xdebug. Here it is essential to validate the remote environment.
Under debug you can set the Debug Port, if you change it to 9001, change it in the php.ini too, choose Can Accept external Connections.
If you do not enable Start to listen for PHP Debug Connection, you have no hope of getting it to work (Icon in upper right corner or down in Run menu).
In Edit Configurations... you have to define a PHP Web Application to be able to use Debug in the Run menu.
It took me a day to get it to work. The main issues being editing the wrong php.ini (do not forget to restart apache after edit) and the fact, that xdebug did not work with the php version.
As you can see I tried a lot of options in my php.ini and ended up using version of xdebug in found in my mamp directory:
;zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so"
zend_extension="/Applications/MAMP/bin/php/php5.5.10/lib/php/extensions/no-debug-non- zts-20121212/xdebug.so"
[xdebug]
;xdebug.var_display_max_children = 999
;xdebug.var_display_max_data = 99999
;xdebug.var_display_max_depth = 100
;xdebug.remote_enable = 1
;xdebug.remote_port=9001
;xdebug.profiler_enable=1
xdebug.remote_connect_back=0
;xdebug.remote_handler=dbgp
;xdebug.remote_host=localhost
;xdebug.profiler_output_dir=/Users/mypath/tmp
xdebug.remote_log=/Users/mypath/xdebug.log
;xdebug.remote_mode=req
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9001
Wish you more speedy success than I had.
In my case, it started working when I changed the port to something other than 9000.
Phpstorm's phpunit command was now:
/usr/bin/php -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9002 -dxdebug.remote_host=10.0.2.2 /var/www/application/vendor/phpunit/phpunit/phpunit --bootstrap /var/www/application/tests/Bootstrap.php --configuration /var/www/application/tests/phpunit.xml <testfile> --teamcity
I'm current running Notepad++ on windows 7 as my primary coding environment. I'm currently looking to debug PHP using the xdebug plugin for Notepad++, DBGp.
Xdebug is set up on the remote server just fine (it's a Ubuntu 10.04 LTS server running apache2 and PHP5). A colleague of mine is running Eclipse on SUSE linux and has Xdebug working just fine on it. However, no matter what configs I try I can't seem to get Xdebug working for me on Notepad++.
I have tried the following guides to get this working with no joy:
http://amiworks.co.in/talk/debugging-php-using-xdebug-and-notepad-part-i/
http://forum.uniformserver.com/index.php?showtopic=1354
http://www.judiwa.com/2010/03/27/how-to-setup-bdgp-debugger-in-notepad-to-debug-php/
http://lamp-dev.com/php-debugging-with-xdebug-dbgp-and-notepad-windows/35
The main problem with these guides seems to be that they assume people are running a local development environment, which I am not.
My current settings for the DBGp plugin are:
remote server IP: {the server IP}
IDE KEY: xdebug
Remote Path: file://Z:/home/garryw/www/idp/650hoursSocialPortal/site
Local Path: Z:
I have also tried:
Remote Path: file:///home/garryw/www/idp/650hoursSocialPortal/site
with no luck either. I have tried so many combinations of Remote Path, Local Path etc... that I'm not sure what else to try now.
On the remote server xdebug is set to map to port 9002 for my user so in PuTTY I set localhost:9000 to map to {server IP}:9002 but this also had no affect....
I'm now incredibly frustrated and can think of nowhere else to turn to for advice... Any suggestions?
I had the same problem.
When I added the xdebug.remote_connect_back = 1 variable in the file / etc/php5/apache2/php.ini worked.
; xdebug configuration starts
zend_extension="/opt/packages/xdebug-2.2.4/modules/xdebug.so"
; Remote settings
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_log=/tmp/xdebug.log
xdebug.remote_connect_back=1
; xdebug configuration ends
You need to setup your putty tunnel the other way around, there is a description here: http://drck.me/xdebug-fw-8r4
As long as your IP + IDEkey setting is correct, Notepad++ will capture the communication with XDebug and you can check it by clicking on the DBG button. If it is empty, you probably have an issue with the port or some other part of the Xdebug config. If it is not empty, you probably have wrong path settings - you can check the messages from Xdebug to see what path it sends. The correct setting is probably file:///home/garryw/www/ (remote) / Z:\home\garryw\www\ (local).