2013-10-01 24 views
7

我在phpstorm中设置了php.iniDebug config。尝试调试PHP脚本输出在phpstorm事件日志:在php.ini运行script.php时出错:端口9000正忙

"Error running script.php: Port 9000 is busy" 

末:

 [XDebug] 
     zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so" 
     xdebug.remote_enable=1 
     xdebug.remote_port="9000" (the default port is 9000) 
     xdebug.profiler_enable=1 
     xdebug.profiler_enable_trigger = 1 
     xdebug.profiler_output_dir="/etc/php5/xdebug/profiler_output_dir" 
在pStorm

调试端口也被设置在9000 netstat -na输出,:

tcp  0  0 127.0.0.1:9000   0.0.0.0:*    LISTEN 

如果我设置为其他端口,该怎么办。例如将其设置为10001似乎可以完成这项工作。或者只是如何使其正常工作。我不确定我是否了解xDebug的工作原理。它像运行Debug("script.php")(Shift+F9)在phpstorm与文件中设置断点?

有人有想法吗?

编辑:

来源: http://xdebug.org/docs/remote

xdebug.remote_port 
Type: integer, Default value: 9000 
The port to which Xdebug tries to connect on the remote host. Port 9000 is the default for both the client and the bundled debugclient. As many clients use this port number, it is best to leave this setting unchanged. 

如果我改变端口以外的9000是什么?也许超过50K的东西。

+1

*“端口9000正忙”* - 这意味着另一个应用程序(不是PhpStorm或完全不同的PhpStorm实例)已经在该端口上侦听。 IDE在该端口上侦听(接收连接),而xdebug是连接到IDE的人,而不是其他方式。官方的xdebug文档详细解释了xdebug如何与调试客户端(IDE)协同工作:http://xdebug.org/docs/remote – LazyOne

回答

3

无法识别lsof和netstat在端口上运行的进程的pid。临时最简单的溶剂只是将phpstormphp.ini中的端口更改为其他未实际使用的端口(如10k)。

4

基本上一些其他进程正在使用9000,而不是使用让它去,通常我在同一时间运行

的Windows补丁另一个IDE - >

  1. FIND过程中使用9000

开拓的cmd.exe

的netstat -o

C:\Users\AMC75>netstat -o 

Active Connections 

Proto Local Address   Foreign Address  State   PID 
TCP 10.6.176.132:27018  livlt0124661:55375  ESTABLISHED  11104 
TCP 10.6.176.132:49271  chilynfe01:5061  ESTABLISHED  10120 
TCP 10.6.176.132:49379  hhefs14:netbios-ssn ESTABLISHED  4 
TCP 10.6.176.132:49383  chifs08:netbios-ssn ESTABLISHED  4 
TCP 10.6.176.132:51034  157.55.56.143:40002 ESTABLISHED  11104 
TCP 10.6.176.132:51038  db3msgr6011007:https ESTABLISHED  11104 
TCP 10.6.176.132:51049  wb-in-f125:5222  ESTABLISHED  10860 
TCP 10.6.176.132:51282  wpapp020:50124   ESTABLISHED  848 
TCP 10.6.176.132:53014  ec2-107-23-104-135:https ESTABLISHED  10860 
TCP 10.6.176.132:53015  ec2-107-23-104-135:https ESTABLISHED  10860 
TCP 10.6.176.132:54774  157.56.116.205:12350 ESTABLISHED  11104 
TCP 10.6.176.132:54822  a23-198-48-60:https CLOSE_WAIT  7500 
TCP 10.6.176.132:55166  upmon070:3306   ESTABLISHED  2652 
TCP 10.6.176.132:55261  lhr08s03-in-f9:http ESTABLISHED  10860 
TCP 10.6.176.132:55570  upmon070:3306   ESTABLISHED  10980 
..... BLAH BLAH BLAH 
  1. 杀死进程

的taskkill/PID XXXX

  1. 利润...?,那么你现在应该能够运行调试
2

的GNU/Linux解决方案(因为有超越Windows的生活):

F继续使用@aqm的解决方案

首先使用端口9000找到进程。

netstat -tulpn | grep :9000 

你会得到这样的输出:

Proto Recv-Q Send-Q Local Address   Foreign Address   State  PID/Program name 

tcp  0  0 127.0.0.1:9000   0.0.0.0:*    LISTEN  3993/programname 

您需要PID与该命令杀死进程:

kill -9 3993 

注意:也许你的过程不显示他的PID,可能你正在运行使用as的PHP-FPM默认端口9000,在这种情况下,您可以更改PHP-FPM端口或PHP Xdebug端口。


的1 - 改变你的Xdebug的配置:

编辑/etc/php/php.ini

搜索xdebug.remote_port=9000,并与新的端口替换


解决方案2 - 修改PHP-FPM端口:

编辑/etc/php/php-fpm.conf

搜索与listen = 127.0.0.1:9000线,并与新的端口

然后重新加载服务替换9000:在

systemctl reload php-fpm 

然后编辑您的nginx或Apache的配置来讲述这个新的端口,搜索127.0.0.1:9000/etc/httpd/httpd.conf/etc/nginx/nginx.conf并用您的新端口替换它

重新加载您的服务器:

systemctl reload nginx 

systemctl reload httpd 

我希望它能帮助:),

合十。

3

纸条给未来的自己:

在我的情况下,这是通过使用虚拟机端口转发(虚拟盒流浪者)造成的。我认为转发9000是个好主意。

SOLUTION:连接到虚拟机的IP 10.166.53.1这是标准的虚框的我/etc/php5/cgi/conf.d/xdebug.ini

; xdebug configuration 
; xdebug.remote_host = localhost 
zend_extension = /usr/lib/php5/20121212/xdebug.so 
xdebug.remote_connect_back = 1 
xdebug.remote_enable = 1 
xdebug.remote_port = 9000 
xdebug.remote_handler = dbgp 
xdebug.remote_mode = req 
xdebug.idekey = "PHPSTORM" 
xdebug.remote_log = /var/log/xdebug.log 
+1

这里同样的问题。显然你不需要转发这个端口。删除端口9000的转发为我解决了它。现在我可以使用Vagrant + XDebug + PhpStorm –

2

首先 enter image description here

内容,哪怕是一点点题外话,我认为它帮助。我为每个docker-composer项目使用不同的网络接口。通过这种方式,我可以在/ etc/hosts中映射一个永久域名而不用担心,在这个例子中是192.168.33.102 project.domain.local

这里是YAML设置的例子:上

nginx: 
    build: docker-images/nginx 
    links: 
    - "php" 
    ports: 
    - "192.168.33.102:80:80" 
php: 
    build: docker-images/php/7.0.1-fpm 
    ports: 
    - "192.168.33.102:10000:9000" 

PHP的容器侦听php7.0-fpm和为xdebug和不暴露任何端口。

PhpStorm调试端口设置为默认值9000,服务器主机设置为192.168.33.102(或来自/ etc/hosts的值为project.domain.local)。

从php容器的端口可以看出,不同的映射端口设置为10000,它可以是任何其他不同于9000的值,以从PhpStorm中删除繁忙的错误。

此外,在docker-compose上绑定端口也很重要。它没有在没有映射端口的情况下工作,并且它不适用于9000:9000

希望它可以帮助别人!

PS:这里是xdebug.ini:

zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so 
xdebug.remote_enable=1 
xdebug.remote_port=9000 
xdebug.remote_connect_back=1 
xdebug.remote_handler=dbgp 
xdebug.remote_mode=req 
xdebug.remote_autostart=true 
7

的过程,这是在端口9000上运行,可能是PhpStorm本身。 9000你只需要改变内置的端口:

检查像雅各当前使用的端口提到的(在Windows CMD:netstat -a -b):下上市 enter image description here

如果PhpStorm.exe IST在服务器的设置>构建,执行,部署>调试器到例如(这是我的队友PhpStorm安装的默认设置)。

+0

我看了很多网页,没有为我工作......直到我尝试了你的建议! (y) – Sebastian

+0

为我工作!我有同样的问题使用9000端口的PHPStorm :) – Avinash

相关问题