[英]Is it possible to use xdebug on Ubuntu?
I am trying to debug some PHP code and wanted to download the XDebug debugger for PHP. 我正在尝试调试一些PHP代码,并希望下载PHP的XDebug调试器。 All I see there is Windows binaries for downloading. 我只看到有用于下载的Windows二进制文件。 Is it at all possible to use it on Ubuntu? 是否可以在Ubuntu上使用它?
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. 下载Xdebug - 如果您的计算机上没有PHP5,则需要按照备用说明进行操作。
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. 包应该为你修改你的INI文件,但是如果你需要自己编辑它并打开它进行以下修改 - 在Ubuntu上它通常在/etc/php5/apache2/php.ini - 添加以下行。
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. 该路径在您的系统上可能略有不同 - 只需确保它是您机器上xdebug.so文件的完全限定路径。 Also remember to comment out any references to the Zend Debugger - you can't run both at the same time. 还记得注释掉任何对Zend Debugger的引用 - 你不能同时运行它们。
Now restart Apache. 现在重启Apache。
sudo /etc/init.d/apache2 restart
You may also need want enable html_errors. 您可能还需要启用html_errors。 Search for html_errors in /etc/php5/apache2/php.ini and make sure it is set to On. 在/etc/php5/apache2/php.ini中搜索html_errors并确保将其设置为On。 A restart of Apache is also required. 还需要重启Apache。
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. 使用phpinfo()仔细检查以确保所有内容都已正确安装 - 您可能还需要在php.ini文件中设置Xdebug的配置。
sudo apt-get install php5-xdebug
On a newer Ubuntu (at least on 14.04 LTS), I needed to activate the module as well. 在较新的Ubuntu(至少14.04 LTS)上,我也需要激活模块。 So, in total I did: 所以,总的来说我做了:
sudo apt-get install php5-xdebug
sudo php5enmod xdebug
After a restart of the server, xdebug was available. 重新启动服务器后,xdebug可用。
This article was what helped me in Ubuntu 16.04 running PHP7: 这篇文章帮助我在运行PHP7的Ubuntu 16.04中帮助我:
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
. :: ubuntu 18.04,php7.2,apache2 :: 1.首先使用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 2.这将创建文件/etc/php/7.2/mods-available/xdebug.ini 3.您可以使用sudo nano /etc/php/7.2/mods-available/xdebug.ini
运行sudo phpenmod xdebug
4. open xdebug.ini sudo nano /etc/php/7.2/mods-available/xdebug.ini
5.你只能看到这一行:zend_extension = xdebug.so 6.假设在localhost和netbeans IDE上运行php apache,将以下行添加到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
NB: xdebug.idekey and xdebug.remote_port can be obtained from netbeans tools->optins->php->debug 注意:xdebug.idekey和xdebug.remote_port可以从netbeans工具 - > optins-> php-> debug获得
Proper way to install XDEBUG for newest version of LAMPP: 正确的方法为最新版本的LAMPP安装XDEBUG:
Download: XDEBUG latest version called source. 下载: XDEBUG最新版本称为源码。
Extract file to any folder. 将文件解压缩到任何文件夹。
Open this folder with terminal. 用终端打开此文件夹。
Change XXX to Your actually version of php 将XXX更改为您的实际版本的PHP
Execute the following commands in your terminal. 在终端中执行以下命令。
/opt/lampp/bin/phpize-XXX ./configure --with-php-config=/opt/lampp/bin/php-config-XXX make cp modules/xdebug.so /opt/lampp/lib/php/extensions/no-debug-non-zts-20170718
Now we need edit file php.ini 现在我们需要编辑文件php.ini
Open folder where is file php.ini in terminal: 打开文件夹,其中是终端中的文件php.ini :
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 在终端中打开LAMPP文件夹
Now restart Apache. 现在重启Apache。
sudo ./xampp restart
And now You can check phpinfo() to see XDEBUG is installed. 现在您可以检查phpinfo()以查看是否已安装XDEBUG。
Try compiling from source, that's what I do on my mac. 尝试从源代码编译,这就是我在mac上做的事情。
Otherwise, this might help you: http://ubuntuforums.org/showthread.php?t=525257 否则,这可能会对您有所帮助: http : //ubuntuforums.org/showthread.php?t = 525257
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.