This article summarizes how to set up xdebug for Apache 2.
Use apt-get to install xdebug from the package repositories. This will also enable xdebug for command line php.
sudo apt-get install php5-xdebug
$ php -v PHP 5.5.3-1ubuntu2 (cli) (built: Oct 9 2013 14:49:12) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
Additionally, I had to manually configure the time zone (sudo vim /etc/php5/apache2/php.ini):
[Date] date.timezone = Europe/Berlin
By default, xdebug is not set for remote debugging. You need to activate it (run sudo vim /etc/php5/apache2/conf.d/20-xdebug.ini):
zend_extension=/usr/lib/php5/20121212/xdebug.so xdebug.remote_enable = 1
After you’re done with the configuration, restart Apache server:
sudo service apache2 restart
Testing in shell
In order to test your installation run the following command:
php -r "phpinfo();phpinfo(INFO_MODULES);" | less
Afterwards, search for xdebug by typing “/xdebug”.
Testing in browser
Place a file phpinfo.php in your web server’s directory and add the following content (set appropriate rights to execute it!):
<html> <body> <?php // Show all information, defaults to INFO_ALL phpinfo(); // Show just the module information. phpinfo(8) yields identical results. phpinfo(INFO_MODULES); ?> </body> </html>
Open up the corresponding URL (e.g. http://localhost/phpinfo.php) and search for xdebug.
Netbeans
For use with Netbeans, you need to correct the debugging session ID. Open the xdebug.ini file:
sudo vim /etc/php5/apache2/conf.d/20-xdebug.ini
Then, add the following line. Make sure, the ID is literally the same as in the Netbeans preferencese:
xdebug.idekey="netbeans-xdebug"