步骤说明

修改xdebug配置

sudo vim /etc/php/7.x/fpm/conf.d/20-xdebug.ini

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.max_nesting_level = 512

改成如下

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.max_nesting_level = 512
xdebug.remote_handler = dbgp
xdebug.idekey = PHPSTORM
xdebug.remote_log = /tmp/xdebug.log

修改保存后重启 php-fpm 服务。

service php7.4-fpm restart

这里会让你输入ssh密码:

我没改过homestead密码所以是:vagrant

➜  fpm service php7.4-fpm restart
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'php7.4-fpm.service'.
Authenticating as: vagrant,,, (vagrant)
Password:

输出phpinfo();可以看到已经成功了