在Debian上使用PhpStorm调试PHP代码步骤如下:
安装Xdebug扩展
sudo apt update
sudo apt install php-xdebug
编辑php.ini
(路径:/etc/php/7.x/apache2/php.ini
或/etc/php/7.x/cli/php.ini
),添加:
zend_extension="xdebug.so"
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.idekey=PHPSTORM
重启Web服务器(如Apache):
sudo systemctl restart apache2
配置PhpStorm
File
> Settings
> Languages & Frameworks
> PHP
> Debug
,勾选Xdebug,设置IDE Key=PHPSTORM
,端口9003
。Settings
> Languages & Frameworks
> PHP
> Servers
,添加服务器,设置主机localhost
、端口80
(或对应端口),调试器选Xdebug。设置断点与启动调试
Shift+F9
启动监听。说明:若使用Nginx,需在站点配置中添加fastcgi_pass
指向PHP-FPM,并确保xdebug.remote_host
与Nginx配置一致。