PortForwardの設定がポイントかな。AWSのインバウンド・アウトバウンドには追記の必要なし。
TeratermのTERATERM.INIに追記
DefaultForwarding=R9001:localhost:9001
TeratermでAWSに接続
ポートフォワーディングセットしてから接続。
xdebugインストール
apt install php-xdebug
php.iniに追記
/etc/php/7.2/cli/php.ini #cliでも使いたいなら
/etc/php/7.2/apache2/php.ini
に追記。
xdebug.remote_port=9001
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_host=localhost
xdebug.remote_log=/tmp/xdebug.log
※ xdebug.soの追記は不要。
VSCodeの設定
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "xdebug",
"type": "php",
"request": "launch",
"port": 9001,
"pathMappings": {
"/var/www/html": "${workspaceFolder}"
}
}
]
}