個人遠程服務器是騰訊雲的ubuntu系統機器,本地個人電腦系統是deepin的系統,使用的IDE是vscode。如今就來使用本地的IDE來調試騰訊雲中爲網站項目
實現邏輯是訪問網站域名後,請求被轉發給騰訊雲本地的9001端口,經過ssh隧道,會直接被轉發給deepin本地系統的9001端口。vscode會監聽9001端口接收到騰訊雲傳遞過來的請求,進入斷點調試模式,結束後會把請求返回給騰訊雲,騰訊雲繼續處理請求php
首先安裝必須的擴展
1.IDE中安裝擴展PHP Debug,直接安裝就行
2.騰訊雲中安裝xdebug的擴展,使用命令apt-get install php-xdebughtml
配置IDE的PHP Debug擴展ubuntu
{ // 使用 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 ubuntu@115.159.28.111app
IDE中啓動監聽模式,打斷點進行調試ssh
詳細操做演示能夠查看個人B站視頻ide