masahiro0104の日記

プログラミング情報メモ

Eclipse + Cent OS 6.7 + Xdebug でリモートデバッグ

前提条件

  • Cent OS と Mac OS でフォルダを共有できていること
  • Cent OS に apach + PHP + Xdebug をインストール済みであること
  • Macファイアウォール設定「外部からの接続をすべてブロック」のチェックを外しておくこと

Cent OS側 設定

xdebug.ini に以下を記載

/etc/php.d/xdebug.ini

; Enable xdebug extension module
zend_extension=/usr/lib64/php/modules/xdebug.so

; see http://xdebug.org/docs/all_settings
xdebug.remote_enable=1
xdebug.remote_log=/tmp/xdebug_remote_log
xdebug.remote_connect_back=1

HTTPサーバ再起動

service httpd restart

Mac OSEclipse設定

Eclipse 環境設定

Eclipse -> 環境設定 -> PHP -> 新規ボタン押下 f:id:masahiro0104:20150926222907p:plainCentOS のIPが「10.211.55.4」の場合
次へ f:id:masahiro0104:20150926222924p:plain 次へ f:id:masahiro0104:20150926222926p:plain 追加 f:id:masahiro0104:20150926222930p:plain CentOS と Mac の共有フォルダ を合わせる。
なお、上記は、CentOSの公開ディレクトリを共有フォルダにしている例 f:id:masahiro0104:20150926222935p:plain 完了 f:id:masahiro0104:20150926222943p:plain OK

Eclipse -> 環境設定 -> PHP -> デバッグ
PHPサーバをCentOSf:id:masahiro0104:20150926222947p:plain 適当にワークスペースPHPプロジェクト及びphpファイルを追加する
追加したphpファイルを右クリック、デバッグ構成選択
PHPサーバ等を変更する。 f:id:masahiro0104:20150926222955p:plain デバッグすれば、PHPファイルの先頭で自動的に止まる。