4,018 views
この記事は最終更新から 2531日 が経過しています。
連載3回目、前回の 「(58)【連載2】VirtualBox上のUbuntuをWEBサーバーにする」 の続きです。
この連載で最終的にやりたいこと
CentOS7を入れた物理サーバーに VirtualBoxをインストールし、
VirtualBoxの仮想マシン上で Ubuntuの仮想サーバーを動かし、
Ubuntuの仮想サーバー上で WEBサーバーを動かし、
eclipse + xdebug, PhpStorm + xdebugでリモートデバッグしたい。
今回やりたいこと
【連載1】前々回の投稿では、
CentOS7を入れた物理サーバーに VirtualBoxをインストールし、Ubuntuの仮想サーバーを動かした。
【連載2】前回の投稿では、
このUbuntuを WEBサーバーとして使い、PHPスクリプトを動かしてMySQLを制御できるようにした。
今回は、
この Ubuntuに Xdebugをインストールし、WindowsパソコンからPHPリモートデバッグできるようにしたい。
とりあえず今回は xdebugのインストールのみ。
(1) 必要なプログラムをインストール
前回の投稿で PHP 7.0を入れたので、ここでも 7.0用のパッケージを入れる。
sudo apt install php7.0-dev php-pear php7.0-xdebug
Xdebugをインストールする。
sudo pecl install xdebug
(2) PHPの設定を変更
Xdebugを有効化する。
※前回の投稿で PHP 7.0を入れたので、その配下の php.iniを編集する。
sudo vi /etc/php/7.0/apache2/php.ini
Xdebug関連の記述を追加する。
zend_extension="/usr/lib/php/20151012/xdebug.so" xdebug.remote_enable=1 xdebug.remote_autostart=1 xdebug.profiler_enable=1 xdebug.profiler_output_dir="/tmp" xdebug.max_nesting_level=1000 xdebug.remote_handler=dbgp xdebug.remote_host=127.0.0.1 ; xdebug.remote_host=192.168.1.6 xdebug.remote_port=9000 xdebug.idekey="XXXXXXXX"
zend_extension は実際に xdebug.soが置かれている場所を設定する。
remote_host は接続相手であるクライアント側に合わせて設定する。
remote_port は接続相手であるクライアント側に合わせて設定する。
idekey は接続相手であるクライアント側に合わせて設定する。
php.iniの変更を反映させるために Apache2を再起動する。
sudo systemctl restart apache2 sudo systemctl status apache2
(3) 設定できたかな?
前回の 「(58) VirtualBox上のUbuntuをWEBサーバーにする」 で作成した phpinfo閲覧ページを見てみる。
Xdebugの情報が列挙されている。無事にインストールできたようだ。