在vscode添加remote ssh插件
输入ssh 主机用户名@主机地址 -A连接远程主机
ssh root@127.0.0.1 -A远程服务器要安装:
1.用VSCODE打开远程服务器对应项目启动断点后,
出现后
2.在远程服务器对应PHP版本中安装对应xdebug
3.在对应PHP版本PHP.ini
[Xdebug] zend_extension=xdebug xdebug.mode = debug,profile xdebug.start_with_request = yes xdebug.output_dir = "/www/wwwlogs/xdebug" xdebug.client_host = localhost xdebug.client_port = 9003 xdebug.profiler_output_name = "cache.out.%t-%s" xdebug.collect_return=1 xdebug.collect_params=1 xdebug.auto_trace=Off xdebug.trace_output_dir=/www/wwwlogs/php_log/php8.2.9nts.xdebug.trace xdebug.profiler_enable=Off xdebug.profiler_output_dir=/www/wwwlogs/php_log/php8.2.9nts.xdebug.profiler xdebug.remote_enable=Off xdebug.remote_host=localhost xdebug.remote_port=9003 xdebug.remote_handler=dbgp4.在对应项目的根目录中创建.vscode/launch.json文件
{ // 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。 // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Listen for Xdebug", "type": "php", "request": "launch", "port": 9003 }, { "name": "Launch currently open script", "type": "php", "request": "launch", "program": "${file}", "cwd": "${fileDirname}", "port": 0, "runtimeArgs": [ "-dxdebug.start_with_request=yes" ], "env": { "XDEBUG_MODE": "debug,develop", "XDEBUG_CONFIG": "client_port=${port}" } }, { "name": "Launch Built-in web server", "type": "php", "request": "launch", "runtimeArgs": [ "-dxdebug.mode=debug", "-dxdebug.start_with_request=yes", "-S", "localhost:0" ], "program": "", "cwd": "${workspaceRoot}", "port": 9003, "serverReadyAction": { "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started", "uriFormat": "http://localhost:%s", "action": "openExternally" } } ] }参考:vscode 使用ssh进行远程开发 (remote-ssh)_vscode remote ssh-CSDN博客