简体   繁体   English

在 ubuntu 中使用 netbeans 调试 php

[英]php debugging with netbeans in ubuntu

I cant make netbeans 6.9 work with xdebug.我不能让 netbeans 6.9 与 xdebug 一起工作。 Strangely I tried telnet奇怪的是我试过telnet

nerkn@nerkn-laptop:~/www/nerkl$ telnet localhost 9000
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
nerkn@nerkn-laptop:~/www/nerkl$ telnet bogaz  9000
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

also I cant find debugclient.我也找不到调试客户端。

xdebug is working: I got logging and pretty error reporting. xdebug 正在工作:我得到了日志记录和漂亮的错误报告。

What can I do?我能做什么? I just want a basic step by step trace.我只想要一个基本的逐步跟踪。

xdebug is working: I got logging and pretty error reporting. xdebug 正在工作:我得到了日志记录和漂亮的错误报告。

You need to enable remote debugging.您需要启用远程调试。

Try this in xdebug.ini :xdebug.ini试试这个:

[xdebug]
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_host = localhost
xdebug.remote_port = 9000

The solution that worked for me;对我有用的解决方案; solved the debugging issue of netbeans it did not solved telnet "Connection refused" issue.解决了netbeans的调试问题它没有解决telnet“连接被拒绝”问题。

My solution:我的解决方案:

In php.ini file (ie located in /etc/php/7.2/apache2/php.ini);在 php.ini 文件中(即位于 /etc/php/7.2/apache2/php.ini); comment the option in [xdebug] section (usually the last section at the end of the file)注释 [xdebug] 部分中的选项(通常是文件末尾的最后一部分)

;xdebug.remote_autostart=on

then restart the apache service然后重启apache服务

sudo systemctl restart apache2.service

try restarting the netbeans if this option was enabled and you disabled it.如果启用了此选项而您禁用了它,请尝试重新启动 netbeans。

@troelskn it not the xdebug.ini file; @troelskn 它不是 xdebug.ini 文件; it is php.ini file.它是 php.ini 文件。



Caution: If for now Xdebug only work with php 7.2.注意:如果现在 Xdebug 只适用于 php 7.2。 (Please only use uptil Xdebug 2.6, because later versions had some issues with debugging). (请只使用直到 Xdebug 2.6,因为以后的版本有一些调试问题)。 So if you had any other version installed like php 7.3 or 7.4 then oyu had to also install php 7.2 along side your current php version (mostly because now by default latest version is installed through apt).因此,如果您安装了任何其他版本,例如 php 7.3 或 7.4,那么 oyu 还必须在您当前的 php 版本旁边安装 php 7.2(主要是因为现在默认情况下,最新版本是通过 apt 安装的)。 and then update in between alternatives.然后在备选方案之间更新。



To set PHP 7.0 as the default, run要将 PHP 7.0 设置为默认值,请运行

update-alternatives --set php /usr/bin/php7.0

To set PHP 7.2 as the default, run要将 PHP 7.2 设置为默认值,请运行

update-alternatives --set php /usr/bin/php7.2

To set PHP 7.3 as the default, run要将 PHP 7.3 设置为默认值,请运行

update-alternatives --set php /usr/bin/php7.3

To set PHP 7.4 as the default, run要将 PHP 7.4 设置为默认值,请运行

update-alternatives --set php /usr/bin/php7.4

Before we can configure Apache to use PHP 7.2, we need to disable the new (or old) version of PHP by typing在我们配置 Apache 以使用 PHP 7.2 之前,我们需要通过键入来禁用 PHP 的新(或旧)版本

a2dismod php7.4

Now enable the newly installed PHP 7.2 version with the following command:现在使用以下命令启用新安装的 PHP 7.2 版本:

a2enmod php7.2

Restart the Apache web server for the changes to take effect:重新启动 Apache Web 服务器以使更改生效:

sudo systemctl restart apache2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM