1. xdebug 一定安裝與php版本一致的,否則載入會失敗。安裝的時候查看一下xdebug的安裝說明 主要是 --with-php-config=/php安裝的bin目錄/php-config 要不然找不到安裝的php的版本資訊。
2. 安裝完成後,在php.ini 中增加 zend 擴充,而不是extension
[XDebug]
zend_extension="/home/lyd/download/xdebug-2.1.4/modules/xdebug.so"
xdebug.profiler_enable = on
xdebug.default_enable = on
xdebug.trace_output_dir="/tmp/xdebug"
xdebug.trace_output_name = trace.%c.%p
xdebug.profiler_output_dir="/tmp/xdebug"
xdebug.profiler_output_name="cachegrind.out.%s"
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=tradeadmin
xdebug.remote_port=9002
要保證程式對/tmp/xdebug有寫入許可權。
3, 重啟php-fpm 和網頁伺服器 ,查看php_info(); 看是否有xdebug的擴充,如果有說明安裝成功。
4. 和開發ide整合 ,以netbeans 為例
netbeans 7.0 中 工具=》選項=》php=》調試
連接埠要和 xdebug.remote_port=9002 設定的一樣,
會話ID: www (這個很重要,可能看 php_info() xdebug擴充一項中的 xdebug.idekey 選項 預設應該是 www)
5. 在項目源檔案中右鍵配製項目的web屬性, 即可。