在 Debian 上使用 PhpStorm 调试的完整步骤
一 前置准备
php -v 查看版本。二 安装与配置 Xdebug
sudo apt update && sudo apt install php-xdebug/etc/php/<version>/cli/php.ini/etc/php/<version>/apache2/php.ini/etc/php/<version>/fpm/php.ini[xdebug]
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.start_with_request=yes
xdebug.idekey=PHPSTORM
zend_extension 需写绝对路径(如:/usr/lib/php/20220829/xdebug.so)。sudo systemctl restart apache2sudo systemctl restart php<version>-fpm三 PhpStorm 端配置
xdebug.client_port 一致)四 开始调试
xdebug.client_host 需设为 PhpStorm 所在机器的 IP。?XDEBUG_SESSION=PHPSTORM,或使用 Xdebug Helper 插件一键开启。五 常见问题排查
php -m | grep xdebug,若无输出,检查 zend_extension 路径与 php.ini 是否生效。xdebug.client_port(如 9004)并同步 PhpStorm 的 Debug port。xdebug.client_host 为 IDE 机器 IP,并开放 9003 端口或配置 SSH 隧道。附 旧版 Xdebug 2 配置提示
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9003
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.mode=debug、xdebug.client_host、xdebug.client_port 等参数,优先使用 3.x 配置。