➜ ~ wget https://xdebug.org/files/xdebug-2.4.1.tgz ➜ ~ tar zxf xdebug-2.4.1.tgz ➜ ~ cd xdebug-2.4.1 ➜ ~ phpize ➜ ~ ./configure --with-php-config=/usr/local/php/bin/php-config ➜ ~ make ➜ ~ make install Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
➜ ~ php -i | grep php.ini Configuration File (php.ini) Path => /usr/local/php/etc Loaded Configuration File => /usr/local/php/etc/php.ini ➜ ~ vim /usr/local/php/etc/php.ini # 追加加入如下配置 [XDebug] ;zend_extension = xdebug.so zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so xdebug.remote_enable = 1 xdebug.remote_handler = dbgp xdebug.remote_port = 9001 xdebug.remote_autostart = 1 xdebug.remote_connect_back = 0 ; 自定义一个 IDE key(session id) xdebug.idekey = vagrant ; 注意此处的 IP 地址是 IDE 所在机器的 IP xdebug.remote_host = 192.168.2.123
# Apache service httpd restart # Nginx service php-fpm restart
PHPStorm 的 xdebug 端口号与
php.ini
配置文件中 xdebug 设置xdebug.remote_port
保持一致,以下图:php
在源码中添加断点,启动 debug 后,在网页运行项目,将自动开始调试模式。vim