I need to debug an PHP application running on a Apache 2 web-server.
But Xdebug doesn't seam to do anything at all; the config is loaded correctly as I can seen in my phpinfo().
zend_extension=xdebug.so
[debug]
xdebug.profiler_enable_trigger = 0
xdebug.profiler_enable = 1
#xdebug.remote_enable = 1
xdebug.profiler_output_dir = "/tmp"
#xdebug.client_host = ip-of-my-desktop
#xdebug.log = "/tmp/xdebug.log"
#xdebug.default_enable = 1
#xdebug.discover_client_host = 1
xdebug.log_level = 10
xdebug.log = "debug"
xdebug.output_dir = /tmp
I tried many combinations but nothing worked.
No profile file are generated an no one tried to connect to my machine on port 90000.
The xdebug.log line had also no effect, no file has been created.
Thanks for your help, I am running out of ideas I managed to get it to work on Debian 9 machine.
xdebug part from phpinfo()
Development Aids โ enabled ๐น
Coverage โ disabled ๐น
GC Stats โ disabled ๐น
Profiler โ disabled ๐น
Step Debugger โ disabled ๐น
Tracing โ disabled ๐น
Directive Local Value Master Value
xdebug.auto_trace (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.cli_color 0 0
xdebug.client_discovery_header no value no value
xdebug.client_host localhost localhost
xdebug.client_port 9003 9003
xdebug.cloud_id no value no value
xdebug.collect_assignments Off Off
xdebug.collect_includes (setting removed in Xdebug 3) (setting removed in Xdebug 3)
xdebug.collect_params (setting removed in Xdebug 3) (setting removed in Xdebug 3)
xdebug.collect_return Off Off
xdebug.collect_vars (setting removed in Xdebug 3) (setting removed in Xdebug 3)
xdebug.connect_timeout_ms 200 200
xdebug.coverage_enable (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.default_enable (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.discover_client_host Off Off
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.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 (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.gc_stats_output_dir (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.gc_stats_output_name gcstats.%p gcstats.%p
xdebug.halt_level 0 0
xdebug.idekey no value no value
xdebug.log debug debug
xdebug.log_level 10 10
xdebug.max_nesting_level 256 256
xdebug.max_stack_frames -1 -1
xdebug.mode develop develop
xdebug.output_dir /tmp /tmp
xdebug.overload_var_dump (setting removed in Xdebug 3) (setting removed in Xdebug 3)
xdebug.profiler_append Off Off
xdebug.profiler_enable (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.profiler_enable_trigger (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.profiler_enable_trigger_value (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.profiler_output_dir (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.profiler_output_name cachegrind.out.%p cachegrind.out.%p
xdebug.remote_autostart (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.remote_connect_back (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.remote_enable (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.remote_host (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.remote_log (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.remote_log_level (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.remote_mode (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.remote_port (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.remote_timeout (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
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 (setting removed in Xdebug 3) (setting removed in Xdebug 3)
xdebug.start_upon_error default default
xdebug.start_with_request default default
xdebug.trace_enable_trigger (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.trace_enable_trigger_value (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.trace_format 0 0
xdebug.trace_options 0 0
xdebug.trace_output_dir (setting renamed in Xdebug 3) (setting renamed in Xdebug 3)
xdebug.trace_output_name trace.%c trace.%c
xdebug.trigger_value no value no value
xdebug.var_display_max_children 128 128
xdebug.var_display_max_data 512 512
xdebug.var_display_max_depth 3 3
PS: I installed the package php-xdebug
PPS: Xdebug v3.0.2
I am uncertain why this is working now.
Now I have this config.
xdebug.mode="debug"
xdebug.trigger_value="XDEBUG_ECLIPSE"
xdebug.start_with_request="yes"
xdebug.client_host="myip"
Cookies and environment variables did not change anything.
Related
Nagiosql generated files make problems during preflight check - but everythings seems to be okay.
/etc/nagios/nagios.cfg
....
## Hosts
cfg_dir=/etc/nagiosql/hosts/
cfg_file=/etc/nagiosql/hosttemplates.cfg
cfg_file=/etc/nagiosql/hostgroups.cfg
cfg_file=/etc/nagiosql/hostextinfo.cfg
cfg_file=/etc/nagiosql/hostescalations.cfg
cfg_file=/etc/nagiosql/hostdependencies.cfg
## Services
cfg_dir=/etc/nagiosql/services/
cfg_file=/etc/nagiosql/servicetemplates.cfg
cfg_file=/etc/nagiosql/servicegroups.cfg
cfg_file=/etc/nagiosql/serviceextinfo.cfg
cfg_file=/etc/nagiosql/serviceescalations.cfg
cfg_file=/etc/nagiosql/servicedependencies.cfg
...
nagios -v /etc/nagios/nagios.cfg
....
Running pre-flight check on configuration data...
Checking services...
Error: There are no services defined!
Checked 0 services.
Checking hosts...
Error: There are no hosts defined!
Checked 0 hosts.
The content seems okay to me
[root#xxx services]# cd /etc/nagiosql/services/
[root#xxx services]# ls -alh
total 20K
drwsr-sr-x 2 apache nagios 4.0K Aug 7 10:46 .
drwsr-sr-x 5 apache nagios 4.0K Aug 7 12:17 ..
-rw-r--r-- 1 apache nagios 2.3K Aug 7 10:46 localhost.cfg
-rw-r--r-- 1 apache nagios 2.2K Aug 7 10:46 www.google.com.cfg
-rw-r--r-- 1 apache nagios 1.1K Aug 7 10:46 www.yahoo.com.cfg
[root#xxx hosts]# ls -alh
total 16K
drwsr-sr-x 2 apache nagios 4.0K Aug 11 07:12 .
drwsr-sr-x 5 apache nagios 4.0K Aug 7 12:17 ..
-rw-r--r-- 1 apache nagios 800 Aug 11 07:12 GIT.cfg
-rw-r--r-- 1 apache nagios 948 Aug 11 07:12 psm01.cfg
Content also seems to be fine (generated by nagiosql):
[root#xxx hosts]# vi GIT.cfg
###############################################################################
#
# Host configuration file
#
# Created by: Nagios QL Version 3.2.0
# Date: 2015-08-11 07:12:54
# Version: Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND ---
# Nagios QL will overwite all manual settings during the next update
#
###############################################################################
define host {
host_name GIT
alias GIT Server
address 172.25.10.80
register 0
}
###############################################################################
#
# Host configuration file
#
# END OF FILE
#
###############################################################################
~
Can somebody tell me where the solution for this problem is? Already wasted 2 hours...
Try removing the final slash from the directory names in your cfg_dir definitions and see if that doesnยดt get it to recognize the cfg files in that directory.
For example,
Change:
cfg_dir=/etc/nagiosql/hosts/
...
cfg_dir=/etc/nagiosql/services/
To:
cfg_dir=/etc/nagiosql/hosts
...
cfg_dir=/etc/nagiosql/services
EDIT:
Okay I think directory permissions may be causing the cfg_dir evaulations to fail. According to the ls -alh output you listed, your /etc/nagiosql/hosts/, /etc/nagiosql/services/, and /etc/nagiosql/ directories do not grant write permissions to the nagios group. Nagios will need to get a directory listing for those directories and will need group write permissions to do it.
To remedy:
chmod g+w /etc/nagiosql/hosts/
chmod g+w /etc/nagiosql/services/
Restart nagios service.
Also, you don't need to remove the slashes from the directory paths in the nagios cfg_dir configurations. Nagios will strip the trailing slash (/) for you, according to the code:
https://github.com/NagiosEnterprises/nagioscore/blob/eb8e83d5d05e572eb8c0d4d4764885c5427b4b69/xdata/xodtemplate.c#L327
/* process all files in a config directory */ else if(!strcmp(var, "xodtemplate_config_dir") || !strcmp(var, "cfg_dir")) {
if(config_base_dir != NULL && val[0] != '/') {
asprintf(&cfgfile, "%s/%s", config_base_dir, val);
} else
cfgfile = strdup(val);
/* strip trailing / if necessary */ if(cfgfile != NULL && cfgfile[strlen(cfgfile) - 1] == '/')
cfgfile[strlen(cfgfile) - 1] = '\x0';
/* process the config directory... */ result = xodtemplate_process_config_dir(cfgfile, options);
my_free(cfgfile);
/* if there was an error processing the config file, break out of loop */ if(result == ERROR)
break; } }
EDIT #2: In the host definition you posted, your register value is set to 0. Try setting it to 1 instead. register 0 is used for templates that will be inherited from, but will not actually show up in the Nagios UI.
Change:
define host {
host_name GIT
alias GIT Server
address 172.25.10.80
register 0
}
To:
define host {
host_name GIT
alias GIT Server
address 172.25.10.80
register 1
}
Also please set register 1 for your service definitions as well.
Try adding executable permissions to your directories. Some programs and languages require +x permissions in order to actually open the directory.
If that doesn't work, temporarily set everything to 0777 permissions to see if the issue is permissions related at all.
You also have config problems even if you get that part working. Your host and service configs don't have a use directive in them, which points to a template that would have most of the default values. The register directive is implied as 1 unless you specifically set it to 0 for a template. See the object definitions docs if you need a reference: https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/3/en/objectdefinitions.html
I'm debugging remotely my project in PhpStorm. IDE shows 'Connected' for a moment and immediately goes into 'Waiting for incoming connection...'
Below is Xdebug log from this session
I: Connecting to configured address/port: X.x.x.x:9000.
I: Connected to client. :-)
> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///xxx/info.php" language="PHP" protocol_version="1.0" appid="4365" idekey="10594"><engine version="2.2.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATAhttp://xdebug.org]></url><copyright><![CDATA[Copyright (c) 2002-2013 by Derick Rethans]]></copyright></init>
<- feature_set -i 0 -n show_hidden -v 1
> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="0" feature="show_hidden" success="1"></response>
<- feature_set -i 1 -n max_depth -v 1
> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_depth" success="1"></response>
<- feature_set -i 2 -n max_children -v 100
> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_children" success="1"></response>
<- status -i 3
> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="status" transaction_id="3" status="starting" reason="ok"></response>
<- step_into -i 4
> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="step_into" transaction_id="4" status="stopping" reason="ok"></response>
<- breakpoint_set -i 5 -t line -f file://xxx/info.php -n 3
> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="5"><error code="5"><message><![CDATA[command is not available]]></message></error></response>
"
According to Xdebug documentation status "stopping" is
'State after completion of code execution. This typically happens at the end of code execution, allowing the IDE to further interact with the debugger engine (for example, to collect performance data, or use other extended commands).'
So my debugger stops before reaching first breakpoint (set on first line).
Could it be a question of server configuration?
You should go to php.ini and delete a line like this
extension=php_xdebug-...
How did this line was created.
You put a xdebug's file into PHP extensions path like this
.../php5.X.XX/ext/
Now you may turn on this PHP extension by any _AMP UI tools like WAMP, XAMPP etc.
To prevent this painful misfortune you must put the Xdebug file into
.../php5.X.XX/zend_ext/
It'll make Xdebug hidden from any _AMP tool.
And correct your zend_extension parameter too.
zend_extension = .../php5.X.XX/ext/php_xdebug-...
to
zend_extension = .../php5.X.XX/zend_ext/php_xdebug-...
It's common default path for it.
Please, remember!
With PHPStorm, Eclipse, Zend etc., possibly you should consider to correct two php.ini files.
The first one for your web server. Commonly under Apache folder
...\Apache2.X.XX\bin\
The second one is for the direct PHP-script debugging. It lies in the PHP hosting folder:
...\php\php5.X.XX\
In my case, the cause of the "breakpoint_set" / "command is not available" problem was disabled xdebug.extended_info option (it is enabled by default but I disabled it for profiling).
Breakpoints do not work then xdebug.extended_info is disabled.
I have got breakpoints worked after reenabling xdebug.extended_info.
I had same problem under windows, with phpstorm, i was googling many time. Eventually, my decision is the:
in php.ini:
xdebug.remote_mode = "jit"
From phpstorm tutorial, JIT - "Just-In-Time" Mode
https://www.jetbrains.com/help/phpstorm/2016.2/configuring-xdebug.html#d43035e303
UPD
No, this option does not helped me actually. But, i resolve my issue in the end:
I use phpstrom for win 7, and i configured the path mapping this way:
d:\serverroot\vhost\www => d:\serverroot\vhost\www
but in my old config i spied such mapping:
d:\serverroot\vhost\www => d:/serverroot/vhost/www
Finally
On windows machines in path mapping in server configuration replace the \ by /
I think the only reason why this could happen is that your info.php has a syntax error. In that case, there is no code to execute and the script goes directly to "stopping" upon issue of the "step_into".
Zend_Opcache / OPCache can cause this issue as well, if you have it enabled try disabling it.
This error can be emitted when the XDebug extension is compiled into a non-debug build of the PHP runtime. The process will not fail (as it shouldn't), but the XDebug extension will stop doing anything for the duration of that process
Why xdebug don't show error trace and var_dump (only php standatr error output)? But debuging is working.
I am working n Mac OS Lion.
Here is my configuration:
[xdebug]
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
; Remote settings
xdebug.remote_autostart=off
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=localhost
xdebug.remote_port=9000
; General
xdebug.show_local_vars=On
xdebug.dump.SERVER=HTTP_HOST, SERVER_NAME
xdebug.dump_globals=On
xdebug.collect_params=4
xdebug.auto_trace=off
xdebug.collect_includes=on
xdebug.collect_return=off
xdebug.default_enable=on
xdebug.extended_info=1
xdebug.manual_url=http://www.php.net
xdebug.show_mem_delta=1
xdebug.max_nesting_level=100
xdebug.idekey=xdebug
; Trace options
xdebug.trace_format=0
xdebug.trace_output_dir=/tmp/xdebug/trace
xdebug.trace_options=0
xdebug.trace_output_name=tracelog
; Profiling
xdebug.profiler_append=0
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_output_dir=/tmp/xdebug/debug
xdebug.profiler_output_name=scriptprofile.out
Make sure to have html_errors set to on (1) in php.ini as well. This is for some odd reason turned off by default in PHP 5.3. In PHP 5.4, the default is on (1) again.
FastCgiIpcDir problems in error log
Hi,
I have noticed in my Apache error logs the following error (error 1):
[Wed Feb 08 14:00:06 2012] [alert] [client 41.185.88.175] (2)No such file or directory: FastCGI: failed to connect to (dynamic) server "/var/www/bin/php-splashpage-user/php-fastcgi": something is seriously wrong, any chance the socket/named_pipe directory was removed?, see the FastCgiIpcDir directive
Directly afterwards followed by this error (error 2):
[Wed Feb 08 14:00:06 2012] [error] [client 41.185.88.175] FastCGI: incomplete headers (0 bytes) received from server "/var/www/bin/php-splashpage-user/php-fastcgi"
How do I fix error 1?
I read about changing this due to the host system cleaning out the "/tmp" directory ( the default dir for fastCgiIpcDir if not defined ) periodically and thus obliterating communication with current active FastCGI services. So I decided to give it a go. I set the FastCgiIpcDir in fastcgi.conf file in hopes of success, but there is simply no change.
This is the contents of my fastcgi.conf file:
<IfModule mod_fastcgi.c>
FastCgiIpcDir /var/lib/apache2/fastcgi_test
FastCgiConfig -idle-timeout 60 -maxClassProcesses 1
FastCgiWrapper On
AddHandler php5-fcgi .php
Action php5-fcgi /cgi-bin/php-fastcgi
<Location "/cgi-bin/php-fastcgi">
Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS
Options ExecCGI
SetHandler fastcgi-script
</Location>
</IfModule>
Permissions and onwerships of /var/lib/apache2/fastcgi_test:
drwxr-xr-x 3 www-data www-data 4.0K 2012-02-08 09:20 fastcgi_test
My php wrapper script php_fastcgi has the following lines:
#!/bin/sh
PHP_FCGI_CHILDREN=120
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=1000
export PHP_FCGI_MAX_REQUESTS
umask 0022
exec /usr/bin/php-cgi -d apc.shm_size=50
I am running PHP 5.3.1, Apache/2.2.14, Ubuntu 10.04.
Here's few things I've picked up so far:
Error 1 only appears at the beginning of an hour say 6 seconds just after the new hour
From working with mod_FastCgi I have learnt that increasing the child processes help relieve some of the "error 2" errors ( which cause the HTTP 500 error at random intervals). Currently I am not quite sure what the affect of error 1 would be, however if error 2 follows directly after then it's safe to say it's not a good thing.
There is very little, if any, full information on errors reported by Fastcgi with tried and tested solutions. Sadly I may just be adding onto the piles of Fastcgi errors posted on the web with no conclusion.
Your help, advice or tips in resolving error 1 would be readily appreciated.
I don't know how to make it work with a wrapper, and suexec, but you should try this:
http://blog.kmp.or.at/2013/06/apache-2-2-on-debian-wheezy-w-php-fpm-fastcgi-apc-and-a-kind-of-suexec/
The solution in the link does not even use suexec, nor the wrapper, and that way at least it works.
The steps required for that:
0) install php5-fpm, and apache-mpm-worker if not already installed
1) comment this line :
#FastCgiWrapper On
2) make an alias:
Alias /cgi-bin/php-fastcgi **/var/something**
3) fastcgiexternalserver:
FastCgiExternalServer **/var/something** -socket php5-fpm-site1user.sock
(The strongly typed paths must be the same)
4) set up the conf in php5-fpm/pool.d/site1user.conf
[site1user]
user = site1user
group = site1user
listen = /var/run/php5-fpm-site1user.sock
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /
5) restart fpm
service php5-fpm restart
6) for deeper understanding check my other answer here
https://serverfault.com/questions/524708/php5-fpm-apache2-on-wheezy-connect-failed-with-fastcgi/536277#536277
According to this article, http://devzone.zend.com/article/2803, var_dump is supposed to beautify the outputs.
I have installed xdebug on my local host with PHP Version 5.3.3-1ubuntu9.2.
I have this in my php.ini outputs.
This program makes use of the Zend
Scripting Language Engine: Zend Engine
v2.3.0, Copyright (c) 1998-2010 Zend
Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans
However when I use var_dump(), nothing changes.
Does xdebug really beautify the var_dump outputs?
If so, how can I fix it?
This is my details of xdebug in php.ini
xdebug
xdebug support enabled
Version 2.1.0
Supported protocols Revision
DBGp - Common DeBuGger Protocol $Revision: 1.145 $
Directive Local Value Master Value
xdebug.auto_trace Off Off
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.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.idekey netbeans-xdebug netbeans-xdebug
xdebug.manual_url http://www.php.net http://www.php.net
xdebug.max_nesting_level 100 100
xdebug.overload_var_dump On On
xdebug.profiler_aggregate Off Off
xdebug.profiler_append Off Off
xdebug.profiler_enable On On
xdebug.profiler_enable_trigger Off Off
xdebug.profiler_output_dir /tmp /tmp
xdebug.profiler_output_name cachegrind.out.%p cachegrind.out.%p
xdebug.remote_autostart Off Off
xdebug.remote_connect_back Off Off
xdebug.remote_cookie_expire_time 3600 3600
xdebug.remote_enable On On
xdebug.remote_handler dbgp dbgp
xdebug.remote_host localhost localhost
xdebug.remote_log no value no value
xdebug.remote_mode req req
xdebug.remote_port 9000 9000
xdebug.scream Off Off
xdebug.show_exception_trace Off Off
xdebug.show_local_vars Off Off
xdebug.show_mem_delta Off Off
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
Thanks in advance.
You need to have html errors turned on in your php config as well