IDEA+PHP+XDebug調試配置


XDebug調試配置

臨時需要調試服務器上的PHP web程序,因此安裝xdebug,下面簡單記錄

安裝xdebug

下載最新並解壓

wget https://xdebug.org/files/xdebug-2.5.4.tgz
tar zxvf xdebug-2.5.4.tgz 
cd xdebug-2.5.4/

編譯

按照README里的步驟安裝

./configure --enable-xdebug
···

報錯
>checking Check for supported PHP versions... configure: error: not supported. Need a PHP version >= 5.5.0 and < 7.2.0 (found 5.3.10-1ubuntu3.21)


原來服務器上的php版本比較低:
>PHP 5.3.10-1ubuntu3.26 with Suhosin-Patch (cli) (built: Feb 13 2017 20:37:53) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

最穩妥起見,下載老版本的xdebug,下載2.2.2版本

``` bash
wget https://xdebug.org/files/xdebug-2.2.2.tgz
tar zxvf xdebug-2.2.2.tgz 
cd xdebug-2.2.2/
./configure --enable-xdebug
make

make完成后,modules下面就有了編譯好的xdebug.so:

root@nginx01:/opt/research/xdebug-2.2.2# ll modules/
total 808
drwxr-xr-x 2 root root   4096 Jun 19 14:17 ./
drwxr-xr-x 9 root root   4096 Jun 19 13:10 ../
-rw-r--r-- 1 root root    939 Jun 19 13:09 xdebug.la
-rwxr-xr-x 1 root root 814809 Jun 19 13:09 xdebug.so*

配置

修改php.ini,服務器使用的php5-fpm,配置文件在/etc/php5/fpm/php.ini

修改,增加xdebug配置信息

zend_extension="/opt/research/xdebug-2.2.2/modules/xdebug.so"
xdebug.remote_enable = On
xdebug.remote_handler = dbgp
xdebug.remote_port = 9001 #端口9001
xdebug.remote_connect_back = 1 
#xdebug.remote_host= 192.168.xxx.xxx
xdebug.idekey = PHPSTORM
xdebug.remote_log = /opt/research/xdebug-2.2.2/xdebug.log

IDEA 配置

配置xdebug端口為9001

在設置里搜索XDEBUG,配置端口9001
enter description here

調試配置

在RUN-Edit Configuratins里,新增PHP Web Application
enter description here

Server新增服務器地址,Debugger設置為Xdebug,將服務器上的絕對地址,映射到本地

XDEBUG配置

然后就可以啟動調試了


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM