SheenLim08 Posted September 9, 2019 Share Posted September 9, 2019 Hi Guys, I am learning PHP via Netbeans IDE in LinuxMint because it just feels closer to Visual Studio which I used in the past, i am trying to lean more with open source technologies. I spin up a VirtualBox and installed apache2 on ubuntu. I created the netbeans project from my linuxMint to the virtualbox apache2 server (remote server) and configured the virtual directories on the apache2 server. I can the test project successfully, however I cannot seem to debug via Netbeans like toggling a breakpoint to view variable values. I found on the internet i need to configure xdebug and followed this site and used this page https://xdebug.org/wizard.php to create and install my xdebug. I then updated my php.ini file to the following: [xDebug] zend_extension = /usr/lib/php/20170718/xdebug.so xdebug.remote_autostart=on xdebug.remote_enable=on xdebug.remote_handler=dbgp xdebug.remote_host=192.168.56.1 xdebug.remote_connect_back=1 xdebug.remote_port=9000 xdebug.remote_mode=req xdebug.idekey="netbeans-xdebug" While my netbeans session id is configured "netbeans-xdebug" and debugger port to 9000. However, when i set a breakpoint in my code, netbeans seems to be stuck on "Waiting for connection" even it already passed the breakpoint. I suspect it's not even connected at all. I do see from my host laptop (where I am running netbeans) that port 9000 does open when running the project with debug and ufw is turned off in both virtualbox machine and laptop. Any ideas? Quote Link to comment Share on other sites More sharing options...
requinix Posted September 9, 2019 Share Posted September 9, 2019 If it's "waiting for connection" then PHP isn't connecting. From inside the virtual machine, try using telnet to connect back to the host (with Netbeans waiting for the connection): $ telnet 192.168.56.1 9000 You might have to install telnet first. If it connects then your Xdebug settings are off in a way I don't see. If not then there's something preventing the connection - possibly firewall settings. Quote Link to comment Share on other sites More sharing options...
SheenLim08 Posted September 9, 2019 Author Share Posted September 9, 2019 Hi requinix, you are right. telnet connection from my UbuntuServer VM to my laptop:9000 is not successful. The laptop and ubuntu server's ufw service is stopped. I did notice that tcp6 (i guess its ipv6) is listening to :9000 but not the tcp (ipv4): sheenlim08@linuxmint-ltp:~/netbeans-11.1/netbeans/bin$ netstat -tulpn (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN - tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN - tcp6 0 0 ::1:45915 :::* LISTEN 15956/java tcp6 0 0 :::9000 :::* LISTEN 15956/java tcp6 0 0 ::1:631 :::* LISTEN - udp 0 0 127.0.0.53:53 0.0.0.0:* - udp 0 0 0.0.0.0:68 0.0.0.0:* - udp 0 0 0.0.0.0:631 0.0.0.0:* - udp 0 0 0.0.0.0:5353 0.0.0.0:* - udp 0 0 0.0.0.0:42398 0.0.0.0:* - udp 0 0 0.0.0.0:55077 0.0.0.0:* - udp6 0 0 :::58094 :::* 2834/Preload.js --b udp6 0 0 :::46110 :::* - udp6 0 0 :::5353 :::* - But when running ss, it does show it is listening to all ports/IP for 9000 or am I reading that wrong. sheenlim08@linuxmint-ltp:~/netbeans-11.1/netbeans/bin$ ss -tulpn Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port udp UNCONN 0 0 127.0.0.53%lo:53 0.0.0.0:* udp UNCONN 0 0 0.0.0.0:68 0.0.0.0:* udp UNCONN 0 0 0.0.0.0:631 0.0.0.0:* udp UNCONN 0 0 0.0.0.0:5353 0.0.0.0:* udp UNCONN 0 0 0.0.0.0:55077 0.0.0.0:* udp UNCONN 0 0 *:58094 *:* users:(("skypeforlinux",pid=2834,fd=55)) udp UNCONN 0 0 [::]:46110 [::]:* udp UNCONN 0 0 [::]:5353 [::]:* tcp LISTEN 0 128 127.0.0.53%lo:53 0.0.0.0:* tcp LISTEN 0 5 127.0.0.1:631 0.0.0.0:* tcp LISTEN 0 50 [::1]:45915 [::]:* users:(("java",pid=15956,fd=20)) tcp LISTEN 0 50 *:9000 *:* users:(("java",pid=15956,fd=271)) tcp LISTEN 0 5 [::1]:631 [::]:* sheenlim08@linuxmint-ltp:~/netbeans-11.1/netbeans/bin$ Any idea how to configure netbeans to also listen to ipv4 for xdebug? Quote Link to comment Share on other sites More sharing options...
requinix Posted September 9, 2019 Share Posted September 9, 2019 It's listening for both IPv4 and IPv6. Which is fine. Try to telnet to the laptop from the laptop. The URL of the (virtual) site is 192.168.something, right? Not localhost or some other subnet? Quote Link to comment Share on other sites More sharing options...
SheenLim08 Posted September 9, 2019 Author Share Posted September 9, 2019 telnet failed from laptop to laptop..hmmm..this is the result when I telnet to my laptop, and it stays that way until i close the terminal tab. I am doing this when the netbeans debugger is running (when the port 9000 is opened). sheenlim08@linuxmint-ltp:~/netbeans-11.1/netbeans/bin$ telnet 192.168.56.1 9000 Trying 192.168.56.1... Connected to 192.168.56.1. Escape character is '^]'. I am not sure how to answer the 2nd question. URL to the apache2 virtual host is www.phptutorial.com, the ip resolves to 192.168.56.101. I edited the laptop's hostfile /etc/hosts so that www.phptutorial.com points to the Ubuntu Server VM ip address to 192.168.56.101. So when I visit/ran the project via webserver, i just type in http://www.phptutorial.com from my laptop. Any recommendations about telnet connection to 9000? Quote Link to comment Share on other sites More sharing options...
requinix Posted September 10, 2019 Share Posted September 10, 2019 9 hours ago, SheenLim08 said: telnet failed from laptop to laptop.. So it does not connect? 9 hours ago, SheenLim08 said: hmmm..this is the result when I telnet to my laptop, and it stays that way until i close the terminal tab. I am doing this when the netbeans debugger is running (when the port 9000 is opened). sheenlim08@linuxmint-ltp:~/netbeans-11.1/netbeans/bin$ telnet 192.168.56.1 9000 Trying 192.168.56.1... Connected to 192.168.56.1. Escape character is '^]'. So it does connect? First step is making sure the laptop can connect to itself. Then, when that's working, you try to get the VM to connect. Is it possible there's some VirtualBox settings required to make outbound connections? If you can browse the site from the laptop then at least inbound works. 9 hours ago, SheenLim08 said: I am not sure how to answer the 2nd question. I was looking for, in other words, 9 hours ago, SheenLim08 said: URL to the apache2 virtual host is www.phptutorial.com, the ip resolves to 192.168.56.101. I edited the laptop's hostfile /etc/hosts so that www.phptutorial.com points to the Ubuntu Server VM ip address to 192.168.56.101. So when I visit/ran the project via webserver, i just type in http://www.phptutorial.com from my laptop. ^ that. Quote Link to comment Share on other sites More sharing options...
SheenLim08 Posted September 10, 2019 Author Share Posted September 10, 2019 Hi requinix, Sorry for the confusion, both laptop and VM does connect to the 192.168.56.1 9000 with the same output. I attached screenshot of both result. I also attached the netbeans screenshot when it does run the debug but is stuck on "Waiting For Connection". even though port 9000 is opened. Quote Link to comment Share on other sites More sharing options...
requinix Posted September 10, 2019 Share Posted September 10, 2019 Oh, so that's all good then. Use phpinfo() to double-check that the Xdebug settings are what they should be. Otherwise... well, I've never once been able to get Xdebug working the first time, there's always been one little thing I've missed... with that said, the settings do look right... Quote Link to comment Share on other sites More sharing options...
SheenLim08 Posted September 10, 2019 Author Share Posted September 10, 2019 (edited) Below is the phpinfo() from the ubuntu server. xdebug xdebug support => enabled Version => 2.7.2 IDE Key => netbeans-xdebug Support Xdebug on Patreon: https://www.patreon.com/bePatron?u=7864328 Supported protocols DBGp - Common DeBuGger Protocol Directive => Local Value => Master Value xdebug.auto_trace => Off => Off xdebug.cli_color => 0 => 0 xdebug.collect_assignments => Off => Off xdebug.collect_includes => On => On xdebug.collect_params => 0 => 0 xdebug.collect_return => Off => Off xdebug.collect_vars => Off => Off xdebug.coverage_enable => On => On xdebug.default_enable => On => On xdebug.dump.COOKIE => no value => no value xdebug.dump.ENV => no value => no value xdebug.dump.FILES => no value => no value xdebug.dump.GET => no value => no value xdebug.dump.POST => no value => no value xdebug.dump.REQUEST => no value => no value xdebug.dump.SERVER => no value => no value xdebug.dump.SESSION => no value => no value xdebug.dump_globals => On => On xdebug.dump_once => On => On xdebug.dump_undefined => Off => Off xdebug.extended_info => On => On xdebug.file_link_format => no value => no value xdebug.filename_format => no value => no value xdebug.force_display_errors => Off => Off xdebug.force_error_reporting => 0 => 0 xdebug.gc_stats_enable => Off => Off xdebug.gc_stats_output_dir => /tmp => /tmp xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p xdebug.halt_level => 0 => 0 xdebug.idekey => netbeans-xdebug => netbeans-xdebug xdebug.max_nesting_level => 256 => 256 xdebug.max_stack_frames => -1 => -1 xdebug.overload_var_dump => 2 => 2 xdebug.profiler_aggregate => Off => Off xdebug.profiler_append => Off => Off xdebug.profiler_enable => Off => Off xdebug.profiler_enable_trigger => Off => Off xdebug.profiler_enable_trigger_value => no value => no value xdebug.profiler_output_dir => /tmp => /tmp xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p xdebug.remote_addr_header => no value => no value xdebug.remote_autostart => On => On xdebug.remote_connect_back => On => On xdebug.remote_cookie_expire_time => 3600 => 3600 xdebug.remote_enable => On => On xdebug.remote_handler => dbgp => dbgp xdebug.remote_host => 192.168.56.1 => 192.168.56.1 xdebug.remote_log => no value => no value xdebug.remote_mode => req => req xdebug.remote_port => 9000 => 9000 xdebug.remote_timeout => 200 => 200 xdebug.scream => Off => Off xdebug.show_error_trace => Off => Off xdebug.show_exception_trace => Off => Off xdebug.show_local_vars => Off => Off xdebug.show_mem_delta => Off => Off xdebug.trace_enable_trigger => Off => Off xdebug.trace_enable_trigger_value => no value => no value xdebug.trace_format => 0 => 0 xdebug.trace_options => 0 => 0 xdebug.trace_output_dir => /tmp => /tmp xdebug.trace_output_name => trace.%c => trace.%c xdebug.var_display_max_children => 128 => 128 xdebug.var_display_max_data => 512 => 512 xdebug.var_display_max_depth => 3 => 3 Edited September 10, 2019 by requinix cropped out everything but xdebug, added [code] Quote Link to comment Share on other sites More sharing options...
kicken Posted September 10, 2019 Share Posted September 10, 2019 Try disabling xdebug.remote_connect_back, that is intended for when you can't set xdebug.remote_host to a specific IP. Also make sure you're configuring the correct PHP setup. The PHP run by apache and the PHP run on the command line can and usually do have different configuration files. If your only editing the CLI configuration but testing via apache that would explain things. Run your phpinfo() function by creating a page and loading it to check what configuration apache is using. Quote Link to comment Share on other sites More sharing options...
SheenLim08 Posted September 10, 2019 Author Share Posted September 10, 2019 (edited) Hi kicken, I think you are correct, i ran the phpinfo() inline to the php files and ran it on apache. There is on xdebug.remote* entries on the page. How do i correct this? * Sorry for this noob question. Edited September 10, 2019 by SheenLim08 Just updating the formatting of the reply. Quote Link to comment Share on other sites More sharing options...
SheenLim08 Posted September 10, 2019 Author Share Posted September 10, 2019 (edited) I got it resolved!!!! Thanks for all of your help and more power to this community. Here is what i did (Kicken and requinix was very helpful). added phpinfo() in one of my php pages. as in (Like Kicken recommends) <?php phpinfo(); include_once "./login.php"; spl_autoload_register(function ($className) { $file = __DIR__ . '\\' . $className . ".php"; $file = str_replace('\\', DIRECTORY_SEPARATOR, $file); if (file_exists($file)) { include_once $file; } }); I noticed that the php.ini file loaded in the apache server is different from the php.ini file on the php interactive, which was the one i was configuring. APACHE: Loaded Configuration File /etc/php/7.2/apache2/php.ini PHP Interactive: Loaded Configuration File => /etc/php/7.2/cli/php.ini I updated the "/etc/php/7.2/apache2/php.ini" with the following values. [xDebug] zend_extension = /usr/lib/php/20170718/xdebug.so xdebug.remote_autostart=on xdebug.remote_enable=on xdebug.remote_handler=dbgp xdebug.remote_host=192.168.56.1 xdebug.remote_connect_back=1 xdebug.remote_port=9000 xdebug.remote_mode=req xdebug.idekey="netbeans-xdebug" Restarted Apache server. My Guess is, /etc/php/7.2/cli/php.ini is what the PHP Builtin web server uses, this makes sense because projects that uses php built-in web server are usually where both PHP and Netbeans are installed on the same host. I learned something new today, thank you again guys.!! Edited September 10, 2019 by SheenLim08 correcting typos. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.