2013-10-01 25 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

相關問題