我的遠程服務器是騰訊云的ubuntu系統機器,本地我的電腦系統是deepin的系統,使用的IDE是vscode,現在就來使用本地的IDE來除錯騰訊云中為網站專案
實作邏輯是訪問網站域名后,請求被轉發給騰訊云本地的9001埠,通過ssh隧道,會直接被轉發給deepin本地系統的9001埠,vscode會監聽9001埠接收到騰訊云傳遞過來的請求,進入斷點除錯模式,結束后會把請求回傳給騰訊云,騰訊云繼續處理請求
首先安裝必須的擴展
1.IDE中安裝擴展PHP Debug,直接安裝就行
2.騰訊云中安裝xdebug的擴展,使用命令apt-get install php-xdebug
配置IDE的PHP Debug擴展

{ // 使用 IntelliSense 了解相關屬性, // 懸停以查看現有屬性的描述, // 欲了解更多資訊,請訪問: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Listen for XDebug", "type": "php", "request": "launch", "port": 9001, "pathMappings": { "/var/www/html/vscode/":"${workspaceRoot}" } }, { "name": "Launch currently open script", "type": "php", "request": "launch", "program": "${file}", "cwd": "${fileDirname}", "port": 9001 } ] }
配置PHP-FPM的php.ini的xdebug
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_host = 127.0.0.1
xdebug.remote_port = 9001
xdebug.remote_log = /tmp/xdebug.log

通過SSH隧道開啟遠程埠轉發,把騰訊云的9001埠轉發給deepin本地的9001埠
ssh -R 9001:127.0.0.1:9001 [email protected]
IDE中啟動監聽模式,打斷點進行除錯

詳細操作演示可以查看我的B站視頻
https://www.bilibili.com/video/av71667758/
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/134876.html
標籤:PHP
