安裝xdebug
-
下載xdebug
可到 xdebug官網 下載與自己PHP版本對應的xdebug擴展 - 安裝
[root] # cd /usr/local/src
[root] # tar zxvf xdebug-2.6.0RC2.tgz
[root] # cd xdebug-2.6.0RC2
[root] # /usr/local/php/bin/phpize
[root] # ./configure --enable-xdebug --with-php-config=/usr/local/php/bin/php-config
[root] # make && make install
- 配置xdebug
修改php.ini配置文件,在文件中追加以下內容zend_extension=xdebug.so //指定Xdebug擴展文件的路徑 xdebug.remote_enable=1 //是否開啓遠程調試 xdebug.remote_handler=dbgp //指定遠程調試的處理協議 xdebug.remote_mode=req //可以設爲req或jit,req表示腳本一開始運行就連接遠程客戶端,jit表示腳本出錯時才連接遠程客戶端。 xdebug.remote_host=192.168.1.98 //指定遠程調試的主機名(安裝phpstorm的主機ip) xdebug.remote_port=9001 //指定遠程調試的端口號 xdebug.idekey="PHPSTORM" //指定傳遞給DBGp調試器處理程序的IDE Key
其他配置項見官網
配置phpstorm
- 彈出設置窗口(file->settings or ctrl+alt+S)
- 設置調試端口,需要與php.ini中的配置一致
- 配置調試主機
- 測試