To enable xDebug in your nginx server you just first install xdebug by pecl command.
sudo pecl install xdebug
Now xdebug is installed in your system. Now find exactly where xdebug.so file was downloaded.
You have to find it in /usr/lib/php5/(somewhere in this directory)
Now after find the xdebug.so you have to open your PHP5-FPM’s php.ini file with
sudo gedit /etc/php5/fpm/php.ini and add the following command (to locate the xdebug and enabling it).
zend_extension=locationOfYourxDebugfile xdebug.remote_port=9000 xdebug.remote_enable=On xdebug.remote_connect_back=On xdebug.remote_log=/var/log/xdebug.log
Now restart your nginx and php5-fpm to load this xdebug. In this same way you can install xdebug for your Apache2.
For apache, setup like the above and after configuring just restart your apache. And you are done!