Is it possible to use xdebug on Ubuntu?

丶灬走出姿态 提交于 2019-11-28 15:43:00
Jarrod Nettles

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.

Parris Varney
sudo apt-get install php5-xdebug

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.

This article was what helped me in Ubuntu 16.04 running PHP7:
Link to article

sudo apt-get install php-xdebug

::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

Proper way to install XDEBUG for newest version of LAMPP:

  1. Download: XDEBUG latest version called source.

  2. Extract file to any folder.

  3. Open this folder with terminal.

  4. Change X.X.X to Your actually version of php

  5. 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

  1. Open folder where is file php.ini in terminal:

    sudo nano ./php.ini
    
  2. Add to the end of file this:

    zend_extension = /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718/xdebug.so
    
  3. Open LAMPP folder in terminal

  4. Now restart Apache.

    sudo ./xampp restart
    

And now You can check phpinfo() to see XDEBUG is installed.

Try compiling from source, that's what I do on my mac.

Otherwise, this might help you: http://ubuntuforums.org/showthread.php?t=525257

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!