Vagrant側の設定
サーバーにログイン
vagrant ssh
peclコマンドをインストール
(php7の場合、pearのバージョンは1.10.0以降でないと上手く動かない)
sudo yum --enablerepo=remi-php70 install php-pear
pear -V
PEAR Version: 1.10.5
PHP Version: 7.0.11
Zend Engine Version: 3.0.0
xdebug インストール
pecl install xdebug
You should add "zend_extension=/usr/lib64/php/modules/xdebug.so" to php.ini
php.iniにパラメータを設定
zend_extension=xdebug.so ← Apacheの場合はフルパス指定「/usr/lib64/php/modules/xdebug.so」
xdebug.remote_enable = On
xdebug.remote_connect_back = On
xdebug.remote_autostart = On
xdebug.remote_host = 192.168.33.1 ← echo $_SERVER["REMOTE_ADDR"]; の値
xdebug.remote_port = 9001 ← ローカルPCにて lsof -i :9001 コマンドを使用し、使用されていないポートか確認
xdebug.idekey="HOGEhoge" ← IDE側の設定で使用する
環境変数PHP_IDE_CONFIGを設定
Apache
SetEnv PHP_IDE_CONFIG serverName=FUGAfuga
nginx
fastcgi_param PHP_IDE_CONFIG serverName=FUGAfuga;
cliで実行する場合
vagrantユーザーの~/.bashrc に設定
export PHP_IDE_CONFIG="serverName=FUGAfuga"
source .bashrc
サーバー再起動
nginx
sudo service nginx restart
sudo service php-fpm restart
Apache
sudo service httpd restart
設定を確認
php -i | grep xdebug
IDE側の設定
接続するリモートホストを設定する
- RUN → Edit Configurations を選択
- ダイアログ左上にある「+」を押下し、PHP Remote Debugを選択






1. RUN → Start Listening for PHP Debug Connections をチェック
ブレークポイントをはり、処理の途中でデバッグができるようになりました。