NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Remote debugging with Xdebug: roadmap needed!

 
Post new topic   Reply to topic    NetBeans Forums -> PHP Users
View previous topic :: View next topic  
Author Message
jhsachs



Joined: 25 Dec 2010
Posts: 45
Location: Northern California

PostPosted: Tue Jul 31, 2012 2:02 pm    Post subject: Remote debugging with Xdebug: roadmap needed! Reply with quote

I'm debugging my PHP projects with XDebug and NetBeans 7.0.1, on my development system (Windows 7) with a local server, then uploading them to a remote (Linux) server.

I also want to be able to use NetBeans, still running on my development system, to debug projects with XDebug on the remote server.

I'm having some difficulty figuring out how to approach this. The documentation I've found seems to describe the details (e.g., how to set up an alternate run configuration) without explaining the concepts (whether setting up an alternate run configuration will get me where I want to go).

Right now I'm puzzling over a tutorial titled "Deploying a PHP Application on a Remote Web Server Using the NetBeans IDE" (http://netbeans.org/kb/docs/php/remote-hosting-and-ftp-account.html). I think this describes the steps I need to perform, but it's going to require a substantial amount of work -- starting with a NetBeans upgrade -- and I want to confirm that I'm on the right path before I pursue it.

This tutorial describes how to set up an additional run configuration that will run a project remotely when the project is already set up to run locally. That's exactly what I want to do.

But the tutorial is silent about whether it's possible to debug the project while it is running remotely. All it says about debugging is that "you can create and debug your PHP project locally and then deploy it on the remote server"... a tantalizing but essentially meaningless statement, since I can do that now without any of the stuff that the tutorial explains!

Is this the right technique for me? If not, where should I look?
Back to top
Ramratan Gupta
Posted via mailing list.





PostPosted: Tue Jul 31, 2012 3:32 pm    Post subject: Remote debugging with Xdebug: roadmap needed! Reply with quote

Hi,
You can login via remote like vnc teamviewer and configure netbean on linux server, I think you can debug there localy via remote login.
Sincerely,
Ramratan Gupta
http://in.linkedin.com/in/ramratangupta


Sent from my Samsung Mobile On 31 Jul 2012 19:32, "jhsachs" <address-removed ([email]address-removed[/email])> wrote:
Quote:
I'm debugging my PHP projects with XDebug and NetBeans 7.0.1, on my development system (Windows 7) with a local server, then uploading them to a remote (Linux) server.

I also want to be able to use NetBeans, still running on my development system, to debug projects with XDebug on the remote server.

I'm having some difficulty figuring out how to approach this. The documentation I've found seems to describe the details (e.g., how to set up an alternate run configuration) without explaining the concepts (whether setting up an alternate run configuration will get me where I want to go).

Right now I'm puzzling over a tutorial titled "Deploying a PHP Application on a Remote Web Server Using the NetBeans IDE" (http://netbeans.org/kb/docs/php/remote-hosting-and-ftp-account.html). I think this describes the steps I need to perform,
Back to top
jhsachs



Joined: 25 Dec 2010
Posts: 45
Location: Northern California

PostPosted: Wed Aug 01, 2012 3:59 am    Post subject: Reply with quote

Ramratan: I appreciate your suggestion, but running NetBeans on the remote server would be a very poor second choice. It would have numerous disadvantages... the most serious being that keeping the two codebases in synch would be very awkward. I would much prefer to find out how to do what I originally proposed.
Back to top
paolosca



Joined: 09 Sep 2010
Posts: 384

PostPosted: Thu Aug 02, 2012 8:39 am    Post subject: Remote debugging with Xdebug: roadmap needed! Reply with quote

Hi,

I think there is no problem using xdebug from a remote server but your
workstation will need to be accessible from the internet since xdebug
will have to connect back to you on port 9000.

This means you will either need to have a public IP number or to setup
port forwarding in your router or firewall to make your workstation
accessible from the internet.

Be aware that it's probably not very secure to setup xdebug on a
production server and it will make your server slower so I suggest you
disable xdebug whenever you don't need to debug your code.


Regards,


Paolo.
Back to top
jhsachs



Joined: 25 Dec 2010
Posts: 45
Location: Northern California

PostPosted: Sat Aug 04, 2012 7:23 pm    Post subject: Reply with quote

OK... as another thread I've started will show, I've begun setting this up. It's taking a while because I'm doing it in spare moments, but I don't foresee any technical problems so far.

I do have a practical problem, though. I've found that NetBeans views the remote site as a "mirror" of a local directory. Consequently there must be a fully populated local directory, which serves no purpose except to comply with NetBeans' remote project design.

My problem is that a complete set of project files occupies close to 500 MB of disk space. Even on a modern hard disk, that's significant chunk. Furthermore, most of the files are images and PDFs, which have nothing to do with the problem I'm debugging, and never change. From my perspective they're just duplicate files filling up my disk. And there's a real possibility that I'll have to debug several versions of the site concurrently, which will mean several 500 MB chunks out of my development system's hard disk.

Is there any way to avoid this "mirror of a local directory" design, and the need to keep a local copy of the whole site?
Back to top
paolosca



Joined: 09 Sep 2010
Posts: 384

PostPosted: Mon Aug 06, 2012 8:05 am    Post subject: Remote debugging with Xdebug: roadmap needed! Reply with quote

Hi,

By design you need to have a copy to work on, this can even be one on
the server if you map it as a local directory (in this case you will
work on it directly) but it's an extremely slow setup even on a local
network.

This is up to you of course but in the case of a production server you
will need to be extremely careful because if you break something the
system will stop working. It's always better to test the project locally
or on a test server and upload it when you are sure everything is working.


For debugging you don't need a mirror of the whole project but only the
php scripts, I suggest you to setup your local project excluding
directories containing images and pdf files.

Also, you can exclude whole directories from your project in
File->Project properties->Ignored folders, this will prevent netbeans
from scanning those folders and from uploading them to the remote server.

I also work on very large projects and I have the following setup:

1. If on the server there are directories with files uploaded by the
user, I will have the same directories on the local copy without the
user files (mostly empty);

2. If the project contains directories with collections of files for
users to download (as pdf documents, zip files, etc) and are
particularly large I will set them as ignored as ignored and remove them
from the ignored folders list only if I need to upload them;

3. If on the local copy there are directories containing files not
needed to run the project as original high resolution images, DB dumps,
backups of old programs, documentation, etc I set them as ignored so
they are not scanned and are excluded from uploads;


Have a nice day,


Paolo


you can exclude whole directories

On 08/05/2012 03:23 AM, jhsachs wrote:
Quote:
OK... as another thread I've started will show, I've begun setting this up. It's taking a while because I'm doing it in spare moments, but I don't foresee any technical problems so far.

I do have a practical problem, though. I've found that NetBeans views the remote site as a "mirror" of a local directory. Consequently there must be a fully populated local directory, which serves no purpose except to comply with NetBeans' remote project design.

My problem is that a complete set of project files occupies close to 500 MB of disk space. Even on a modern hard disk, that's significant chunk. Furthermore, most of the files are images and PDFs, which have nothing to do with the problem I'm debugging, and never change. From my perspective they're just duplicate files filling up my disk. And there's a real possibility that I'll have to debug several versions of the site concurrently, which will mean several 500 MB chunks out of my development system's hard disk.

Is there any way to avoid this "mirror of a local directory" design, and the need to keep a local copy of the whole site?




Back to top
jhsachs



Joined: 25 Dec 2010
Posts: 45
Location: Northern California

PostPosted: Mon Aug 06, 2012 5:16 pm    Post subject: Reply with quote

Quote:
...in the case of a production server you will need to be extremely careful...


I'm aware of that. The server I'll be testing on is for QA, and I'm doing that only because I need to debug a problem that doesn't appear on the development system. I won't consider debugging on the production server unless the QA server doesn't exhibit the problem either, and that would be an extreme situation indeed.

Quote:
For debugging you don't need a mirror of the whole project but only the
php scripts, I suggest you to setup your local project excluding
directories containing images and pdf files.

Thank you, that sounds like an excellent solution to my problem!

In this context I'm interpreting "excluding directories..." to mean that those directories simply won't appear in the local copy.

Later, if I understood your message correctly, you spoke of "excluding" directories in a sense that concerns the project definition, in effect saying, "This directory isn't part of the project even though it's a subdirectory of a directory that is." I don't understand how that's done, but I gather I can proceed without it.
Back to top
paolosca



Joined: 09 Sep 2010
Posts: 384

PostPosted: Tue Aug 07, 2012 2:25 am    Post subject: Remote debugging with Xdebug: roadmap needed! Reply with quote

Hi,

On 08/07/2012 01:16 AM, jhsachs wrote:
Quote:
In this context I'm interpreting "excluding directories..." to mean that those directories simply won't appear in the local copy.

Yes, for debugging you only need the files which are run by the php
interpreter. When xdebug is active it will take control of the php
interpreter relying debug information to NetBeans.
NetBeans then uses this information to display the current line an
variables values on the code on the screen. Netbeans also need the local
file to inform xdebug about the break points.

The local and remote files need to be identical, even an extra blank
line may result in broken debugging.


Quote:
Later, if I understood your message correctly, you spoke of "excluding" directories in a sense that concerns the project definition, in effect saying, "This directory isn't part of the project even though it's a subdirectory of a directory that is." I don't understand how that's done, but I gather I can proceed without it.

To exclude folders from your project you can go to "File->Project
properties", then choose the "Ignored folders" tab and add the folders
you want to the list.

This is not necessary to debug, it was just a suggestion to keep your
local project light and avoid NetBeans to scan and index gigabytes of
files which are not necessary to run the project.

Excluded folders are still accessible using the "Files" panel.


Have a nice day,


Paolo
Back to top
nissan



Joined: 13 Aug 2012
Posts: 3

PostPosted: Fri Aug 17, 2012 2:29 pm    Post subject: Reply with quote

Quote:
Using Win xp sp3, NetBeans 7.2
I couldn't get 127.0.0.1 to connect to xDebug.
Is 127.0.0.1 a remote_host or a localhost?
At any rate, this worked for me.
;/********************************************************/
zend_extension="C:/PHP/ext/php_xdebug-2.2.1-5.4-vc9.dll"
xdebug.idekey=netbeans-xdebug
xdebug.remote_mode=req
xdebug.remote_host=192.168.1.96
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_log="c:/php/tmp/xdebug/xdebug_remote.log"
;/********************************************************/
Hope this helps,
--Andy
[/quote]
Back to top
jhsachs



Joined: 25 Dec 2010
Posts: 45
Location: Northern California

PostPosted: Mon Aug 27, 2012 2:47 am    Post subject: Reply with quote

I didn't have a chance to work on this for a while. I have now, and I've made progress, but I haven't quite reached the finish line.

I was able to create a remote project without difficulty. I anticipated problems finding the location of the certificate for SFTP, but NetBeans apparently lifted it from Filezilla and set everything up correctly. The "New Project" wizard downloaded the appropriate files from the server to the local project directory.

When I tried to start the project in the debugger, though, NetBeans was unable to connect to the debugger. When I killed the debug run I got a familiar error dialog which listed the relevant pip.ini settings and suggested that the debugger might not be installed.

I've checked out every possibility as far as I can, but haven't found the problem. I'm seeking suggestions.

Here's what I've checked:

From the error dialog:

    xdebug.remote_enable=on
    xdebug.remote_handler=dbgp
    xdebug.remote_host= the IP address of my development system, i.e. of NetBeans' debug client
    xdebug.remote_port=9000

As far as I can tell, these settings are correct and sufficient.

The error dialog doesn't say so, but php.ini also contains

    zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so

I have looked at this directory and confirmed that it exists, and xdebug.so is in it. This xdebug.so is actually a link to

    /usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so


which also exists, and has a length of 743245 bytes.

I don't know whether this is the right xdebug.so, and I'm not sure how to find out. I don't have the root permissions that I need to write to these directories, so the hosting service's tech support people installed the file (and did any other necessary magic) at my request. I have no reason to assume they did it wrong, but I can't verify that they did it right.

It occurred to me that the connection might be blocked by the firewall (in my case, Windows Firewall in Windows 7 Professional). I added inbound and outbound port rules allowing connections on port 9000, but that didn't help. I haven't used this firewall before, though, so I have to allow for the possibility that I made a mistake.
Back to top
paolosca



Joined: 09 Sep 2010
Posts: 384

PostPosted: Tue Aug 28, 2012 5:10 pm    Post subject: Remote debugging with Xdebug: roadmap needed! Reply with quote

On 08/27/2012 10:47 AM, jhsachs wrote:
Quote:
xdebug.remote_host= the IP address of my development system, i.e. of NetBeans' debug client
I don't have the root permissions that I need to write to these directories, so the hosting service's tech support people installed the file (and did any other necessary magic) at my request.

Hi,

From the above information I assume the workstation running NetBeans and
your server are on a different network and they will access each other
through the Internet.

If this is the case you need to make sure your workstation has a public
IP address which should be written in the xdebug.remote_host parameter.
Your LAN address (as 192.168.x.x or 10.x.x.x) won't work.

You have a few options:

1. Configure your router as a bridge;

2. Setup port forwarding in your router in order to forward the packets
it receives on port 9000 in it's external interface to port 9000 of your
workstation;

3. Setup a VPN between your remote server and your LAN;

4. Install an http server in your workstation (or on a test server in
your LAN) and debug locally;


I suggest you to choose option 4 because xdebug will add unnecessary
load to your a production server and it will be a security concern.
Also, being in the same machine/network it will be a lot faster.

If you really must use it on your remote server, I suggest you to
disable xdebug and enable it only when you need it.


Regards,


Paolo
Back to top
jhsachs



Joined: 25 Dec 2010
Posts: 45
Location: Northern California

PostPosted: Tue Aug 28, 2012 6:52 pm    Post subject: Reply with quote

Paolosca, thank you for your effort to help. I need to explain a little more about what's happening.

First, the server is run by a hosting company. They're very helpful, but there are certain things that they simply can't do. I suspect that reconfiguring a router will fall in that category, if the router in question is even under their control. That probably knocks out your suggestions 1 and 2.

Suggestion 4 is definitely inapplicable. I've got a local server already, and the debugger works fine with it, but the problem I need to debug does not present there.

That leaves your suggestion 3, a VPN. I don't know what's involved in setting one up, but from my past experiences with support people who had to set them up for me, I gather that part of it is rocket science and part is voodoo! So it's a possibility, but not an appealing one.

What I'm really hoping for is tools or tricks that will help me determine what is wrong, so that I can fix the problem rather than evade it. Even knowing for certain that the problem is on the server side or the client side would be a big help.
Back to top
paolosca



Joined: 09 Sep 2010
Posts: 384

PostPosted: Wed Aug 29, 2012 4:43 pm    Post subject: Remote debugging with Xdebug: roadmap needed! Reply with quote

On 08/29/2012 02:52 AM, jhsachs wrote:
Quote:
Paolosca, thank you for your effort to help. I need to explain a little more about what's happening.
First, the server is run by a hosting company. They're very helpful, but there are certain things that they simply can't do. I suspect that reconfiguring a router will fall in that category, if the router in question is even under their control. That probably knocks out your suggestions 1 and 2.
Suggestion 4 is definitely inapplicable. I've got a local server already, and the debugger works fine with it, but the problem I need to debug does not present there.
That leaves your suggestion 3, a VPN. I don't know what's involved in setting one up, but from my past experiences with support people who had to set them up for me, I gather that part of it is rocket science and part is voodoo! So it's a possibility, but not an appealing one.
What I'm really hoping for is tools or tricks that will help me determine what is wrong, so that I can fix the problem rather than evade it. Even knowing for certain that the problem is on the server side or the client side would be a big help.

You will need to change the settings of the router that connects your
workstation to the internet, not the one connecting your server (which
already has a public IP).

The point is that xdebug on the server needs to communicate with
NetBeans and it won't be possible if your workstation is not accessible
from the internet.

Port forwarding is probably the easier solution, configure your router
to forward all packets arriving from the Internet on port 9000 (or
whatever port NetBeans is using to connect to xdebug) the IP number of
your workstation.

Finally set the xdebug remote host as your public IP number.

Beware that generally broadband internet connections have a floating IP
number so you will probably need to update your xdebug configuration
every time you need to use it.

You can find your public IP number in the router configuration or here:

http://whatismyip.com

To make sure xdebug is properly installed in the server you can use
phpinfo() and get_loaded_extensions() (see the php manual for details).


Regards,


Paolo
Back to top
jhsachs



Joined: 25 Dec 2010
Posts: 45
Location: Northern California

PostPosted: Wed Aug 29, 2012 9:30 pm    Post subject: Reply with quote

I read up on port forwarding, and I think I have a pretty good understanding of the problem now.

The router is a black box provided by the cable company, and I'll need to ask them to set up the port forwarding (or tell me how to do it). I'm not looking forward to that. All of the black humor about cable company service is true!

A few observations and questions:

My router's internet address is fixed; at least it hasn't changed over the past six weeks. I don't know about the internal IP address; I don't have any old records of it.

Do the internal and external address both need to be fixed? Or does the router know which computer is mine, even if its internal address changes?

phpinfo says that xdebug is loaded, with a version number of 2.2.1 and an IDE key of "no value." I assume that means it's functional... correct?

Later: I realized that I could test the port 9000 connection with Telnet. I tried that, and found that I can't connect to the host on that port.

This is the type of thing I meant when I appealed for tricks or tools that would help me figure out what is wrong.

I think port 9000 is cleared through my workstation's firewall and the host's firewall. That leaves the local router. I'm going to try to configure port forwarding there, but I can do so and the debugger still doesn't work, what then?

It would make my life ever so much easier if I could confirm that traffic can or can't pass through port 9000 at each point! Until I can do that, I can't isolate the problem; I can think I know where the problem is, but I can't be sure.
Back to top
paolosca



Joined: 09 Sep 2010
Posts: 384

PostPosted: Thu Aug 30, 2012 1:37 pm    Post subject: Remote debugging with Xdebug: roadmap needed! Reply with quote

Hi,

On 08/30/2012 05:30 AM, jhsachs wrote:
Quote:
My router's internet address is fixed; at least it hasn't changed over the past six weeks. I don't know about the internal IP address; I don't have any old records of it.

If you never switched off the router is possible you have been assigned
always the same ip address from a floating ip addresses pool.

The internal router ip number is normally fixed (I never seen a
configuration where it wasn't).

Quote:
Do the internal and external address both need to be fixed? Or does the router know which computer is mine, even if its internal address changes?

If the external IP address changes you will have reconfigure xdebug on
the server. If the internal ip address of your workstation changes you
will have to change the port forwarding settings.

You should check your workstation network configuration, if the address
is assigned by dhcp it's possible you will get a different IP address
from time to time. If this becomes a problem you can assign it an IP
address manually.

You can check your workstation IP number with a network utility, in
linux you can use ifconfig, in windows I'm not sure.

Quote:
phpinfo says that xdebug is loaded, with a version number of 2.2.1 and an IDE key of "no value." I assume that means it's functional... correct?

It seems fine to me.

Have a nice day,

Paolo
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> PHP Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo