I am trying to debug some PHP code and wanted to download the XDebug debugger for PHP. All I see there is Windows binaries for downloading. Is it at all possible to use it on Ubuntu?
问题:
回答1:
Execute the following commands in your terminal.
Download Xdebug - you will need to follow alternate instructions if you don't have PHP5 working on your machine already.
sudo apt-get install php5-xdebug
The package should modify your INI file for you, but just in case you need to edit it yourself open it up and make the following modification - on Ubuntu its typically at /etc/php5/apache2/php.ini - add the following line.
zend_extension="/usr/lib/php5/20110331/xdebug.so"
That path might be a little different on your system - just make sure its a fully qualified path to the xdebug.so file on your machine. Also remember to comment out any references to the Zend Debugger - you can't run both at the same time.
Now restart Apache.
sudo /etc/init.d/apache2 restart
You may also need want enable html_errors. Search for html_errors in /etc/php5/apache2/php.ini and make sure it is set to On. A restart of Apache is also required.
html_errors = On
Double-check with phpinfo() to make sure that everything is installed properly - you may also want to set configurations for Xdebug in your php.ini file.
回答2:
sudo apt-get install php5-xdebug
回答3:
On a newer Ubuntu (at least on 14.04 LTS), I needed to activate the module as well. So, in total I did:
sudo apt-get install php5-xdebug
sudo php5enmod xdebug
After a restart of the server, xdebug was available.
回答4:
This article was what helped me in Ubuntu 16.04 running PHP7:
Link to article
sudo apt-get install php-xdebug
回答5:
::ubuntu 18.04, php7.2, apache2::
1. First install xdebug using sudo apt-get install php-xdebug
.
2. This will create file /etc/php/7.2/mods-available/xdebug.ini
3. You can run sudo phpenmod xdebug
4. open xdebug.ini using sudo nano /etc/php/7.2/mods-available/xdebug.ini
5. you can see only the line: zend_extension=xdebug.so
6. assuming running php apache on localhost and netbeans IDE, add following line to xdebug.ini
xdebug.show_error_trace = 1
xdebug.idekey=netbeans-xdebug
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1
N.B: xdebug.idekey and xdebug.remote_port can be obtained from netbeans tools->optins->php->debug
回答6:
Proper way to install XDEBUG for newest version of LAMPP:
Download: XDEBUG latest version called source.
Extract file to any folder.
Open this folder with terminal.
Change X.X.X to Your actually version of php
Execute the following commands in your terminal.
/opt/lampp/bin/phpize-X.X.X ./configure --with-php-config=/opt/lampp/bin/php-config-X.X.X make cp modules/xdebug.so /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718
Now we need edit file php.ini
Open folder where is file php.ini in terminal:
sudo nano ./php.ini
Add to the end of file this:
zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
Open LAMPP folder in terminal
Now restart Apache.
sudo ./xampp restart
And now You can check phpinfo() to see XDEBUG is installed.
回答7:
Try compiling from source, that's what I do on my mac.
Otherwise, this might help you: http://ubuntuforums.org/showthread.php?t=525257