是否可以在Ubuntu上使用xdebug?
我正在尝试调试一些PHP代码,并想下载适用于PHP的XDebug调试器.我所看到的全部是可供下载的Windows二进制文件.可以在Ubuntu上使用它吗?
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?
在终端中执行以下命令.
Execute the following commands in your terminal.
下载Xdebug-如果您的计算机上尚未安装PHP5,则需要按照其他说明进行操作.
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
该软件包应该为您修改INI文件,以防万一您需要自己对其进行编辑以将其打开并进行以下修改-在Ubuntu上,通常为/etc/php5/apache2/php.ini-添加下一行.
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"
该路径在您的系统上可能有所不同-只需确保它是您计算机上xdebug.so文件的完全限定路径即可.还请记住注释掉对Zend Debugger的所有引用-您不能同时运行两者.
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.
现在重新启动Apache.
Now restart Apache.
sudo /etc/init.d/apache2 restart
您可能还需要启用html_errors.在/etc/php5/apache2/php.ini中搜索html_errors并确保将其设置为On.还需要重新启动Apache.
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
使用phpinfo()仔细检查以确保所有内容均已正确安装-您可能还希望在php.ini文件中设置Xdebug的配置.
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.