29

Is There is a way to install Xdebug for Php5 on Ubuntu 16.04? I've tried to install it the same way as ubuntu 14.04 but every time I try to install php5-dev I get this error "E: Package 'php5-dev' has no installation candidate"

Samar
  • 403
  • 1
  • 4
  • 7

1 Answers1

42

you can install xdebug by typing in

sudo apt-get install php-xdebug

then only restart apache

sudo service apache2 restart

or if you use NGINX

sudo systemctl restart nginx

or sudo nginx restart

If you now look at your phpinfo() output, you should see the xdebug.

This als wokrs if u installed PHP 5.5 or 5.6 via ppa:ondrej/php Packages

To install PHP5 version by apt-get look this guid Ubuntu add ondrej/php

Greetings

Edit: Here the config for Xdebug to use it with PHPStorm and the Browser.

Add the following lines to /etc/php//apache2/conf.d/20-xdebug.ini

xdebug.remote_host = localhost
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_mode = req

This will start xdebug only at remote and allows you fast to debug by PHPStorm (should also work with other IDE's)

RlDDlCK
  • 606
  • 5
  • 10
  • 1
    What if I don't use Apache but nginx? How does one add ondrej's ppa to their system? Your answer is incomplete, I suggest you expand it by answering the questions in my comment so it's complete, because the question is really good and you've answered half of it. – Mjh Jul 18 '16 at 12:44
  • 1
    So.. if I use nginx and PHP, how does restarting nginx help me? It doesn't boot PHP like apache does.. – Mjh Jul 18 '16 at 14:17
  • note for other people reading this thread - the apt package to install is "php-xdebug" and not "ext-xdebug" - (took me a while to figure out my own mistake) – sami Aug 18 '16 at 10:31
  • 2
    **sudo apt-get install php5-xdebug** worked for me on _Ubuntu 14.04.5 LTS_ – user2182349 May 30 '17 at 14:10
  • @user2182349 yes but the questions was focused to 16.04. 14.04 came with php5 but 16.04 not – RlDDlCK May 31 '17 at 10:03
  • @ZFNerd Note the difference: **php5** versus plain **php**. `sudo apt-get install php-xdebug` didn't work for me, but `sudo apt-get install php5-xdebug` did. – CJ Dennis Nov 08 '17 at 03:42
  • @CJDennis which Ubuntu do you use? – RlDDlCK Nov 08 '17 at 12:36
  • @ZFNerd Ubuntu 14.04.5, the same as user2182349. I know this question is about 16.04, but it's attracting people who are working with 14.04 as well. I found that comment useful, i.e. it helped me solve my problem. – CJ Dennis Nov 08 '17 at 23:05
  • @CJDennis Yes in Ubuntu 14.4 php5 was the standard deliverd php. but with ubuntu 16.4 php7 is now the standard. and the question was not to install php and xdebug on ubuntu 14.4 ;D – RlDDlCK Nov 09 '17 at 15:42
  • **'php-xdebug' not found in package names. Trying capabilities. No provider of 'php-xdebug' found.** – Black Mar 21 '19 at 10:13
  • @Black which OS? – RlDDlCK Mar 21 '19 at 10:43
  • @ZFNerd, Linux openSUSE Leap 42.3 – Black Mar 21 '19 at 10:45
  • 1
    @Black sry but the Question was for UBUNTU and i dont work with openSuse. So i cant help you – RlDDlCK Mar 21 '19 at 10:52
  • For me with the ondrej/php ppa on Ubuntu 16.04, this did *NOT* work: `sudo apt-get install php5-xdebug` But this DID work: `sudo apt-get install php5.6-xdebug` – jbobbins Nov 26 '19 at 06:43
  • 1
    `apt-get install php5.6-xdebug` works also for ondrej/php ppa on Ubuntu 18.04 – GabrieleMartini Dec 04 '20 at 10:30