📢 Webサイト閉鎖と移転のお知らせ
このWebサイトは2026年9月に閉鎖いたします。
新しい記事は移転先で追加しております。(旧サイトでは記事を追加しておりません)
| (同じ利用者による、間の10版が非表示) | |||
| 22行目: | 22行目: | ||
==== パッケージ管理システムからインストール ==== | ==== パッケージ管理システムからインストール ==== | ||
以下のコマンドを実行する。<br> | 以下のコマンドを実行する。<br> | ||
# | # RHEL | ||
sudo | sudo dnf install php84-php-pecl-xdebug3.x86_64 # PHP 8.4の場合 | ||
php83-php-pecl-xdebug3.x86_64 # PHP 8.3の場合 | |||
# | php82-php-pecl-xdebug3.x86_64 # PHP 8.2の場合 | ||
php81-php-pecl-xdebug3.x86_64 # PHP 8.1の場合 | |||
php81-php-pecl-xdebug3.x86_64 # PHP 8.0の場合 | |||
php74-pecl-xdebug3.x86_64 # PHP 7.4の場合 | |||
# SUSE | # SUSE | ||
sudo zypper install php7-xdebug | sudo zypper install php8-xdebug # PHP 8の場合 | ||
php7-xdebug # PHP 7の場合 | |||
<br> | <br> | ||
==== ソースコードからインストール ==== | ==== ソースコードからインストール ==== | ||
| 55行目: | 58行目: | ||
<br> | <br> | ||
===== Xdebugのインストール ===== | ===== Xdebugのインストール ===== | ||
まず、[https://xdebug.org/download Xdebugの公式Webサイト] | まず、[https://xdebug.org/download Xdebugの公式Webサイト]にアクセスして、Xdebugのソースコードをダウンロードする。<br> | ||
ダウンロードしたファイルを解凍する。<br> | |||
tar xf xdebug-<バージョン名>.tgz | tar xf xdebug-<バージョン名>.tgz | ||
cd xdebug-<バージョン名> | |||
<br> | <br> | ||
<code>phpize</code>コマンドを実行する。<br> | |||
phpize | phpize | ||
<br> | <br> | ||
Xdebugをビルドおよびインストールする。<br> | |||
もし、<code>configure</code>スクリプトの実行に失敗する場合、Xdebugのビルドに必要なライブラリ等が不足している。<br> | |||
mkdir xdebug-build && cd xdebug-build | |||
./configure --enable-xdebug | ../configure \ | ||
< | --enable-xdebug \ | ||
--enable-xdebug-dev \ # 任意 | |||
--prefix=<PHPのインストールディレクトリ> # PHPを任意のディレクトリにインストールしている場合等に指定する | |||
make -j $(nproc) | make -j $(nproc) | ||
make install | |||
または | |||
sudo make install | |||
<br> | <br> | ||
インストールしたxdebug.soファイルの場所は、各LinuxディストリビューションやPHPの環境により異なる。<br> | |||
<br> | <br> | ||
RHELおよびSUSEにおいて、パッケージ管理システムからPHPをインストールした場合は、/usr/lib64/php<PHPのバージョン>/extensionsディレクトリに配置される。<br> | |||
ソースコードからPHPをインストールした場合は、/<PHPのインストールディレクトリ>/lib64/extensions/xxxディレクトリ等に配置される。<br> | |||
<br><br> | <br><br> | ||
| 84行目: | 92行目: | ||
<br> | <br> | ||
<u>Xdebugのバージョンにより、[xdebug]セクションの設定が異なることに注意すること。</u><br> | <u>Xdebugのバージョンにより、[xdebug]セクションの設定が異なることに注意すること。</u><br> | ||
# | # RHEL | ||
sudo vi /etc/php.d/15-xdebug.ini | sudo vi /etc/php.d/15-xdebug.ini # PHPをパッケージ管理システムからインストールしている場合 | ||
sudo vi /<PHPのインストールディレクトリ>/etc/conf.d/xdebug.ini # PHPをソースコードからインストールしている場合 | |||
# SUSE | # SUSE | ||
sudo vi /etc/ | sudo vi /etc/php<span style="color: #C00000">X</span>/conf.d/xdebug.ini # PHPをパッケージ管理システムからインストールしている場合 <span style="color: #C00000">X</span>はPHPのバージョン | ||
sudo vi /<PHPのインストールディレクトリ>/etc/conf.d/xdebug.ini # PHPをソースコードからインストールしている場合 | |||
<br> | <br> | ||
* Xdebug 3.xの設定 | * Xdebug 3.xの設定 | ||
: Xdebug 3.xの標準ポート番号は、9003番に変更されたことに注意すること。 | *: Xdebug 3.xの標準ポート番号は、9003番に変更されたことに注意すること。 | ||
*: <code>xdebug.remote_host</code>は、<code>xdebug.client_host</code>に置き換えられた。 | |||
*: <code>xdebug.remote_port</code>は、<code>xdebug.client_port</code>に置き換えられた。 | |||
*: <code>xdebug.remote_log</code>は、<code>xdebug.log</code>に置き換えられた。 | |||
*: これは Step Debugging以外のログメッセージも含まれる。 | |||
*: <br> | |||
*: <code>xdebug.remote_mode</code>は、以下に示す設定に置き換えられた。 | |||
*:: <code>xdebug.remote_mode=req</code>(デフォルト値)の場合は、<code>xdebug.mode=debug</code>と<code>xdebug.start_with_request=trigger</code>を使用する。 | |||
*:: <code>xdebug.remote_autostart</code>の動作が必要な場合は、<code>xdebug.start_with_request=trigger</code>の代わりに<code>xdebug.start_with_request=yes</code>を使用する。 | |||
*:: <code>xdebug.start_with_request=jit</code>の場合は、<code>xdebug.mode=debug</code>および<code>xdebug.start_upon_error=yes</code>を使用する。 | |||
# 1行目を編集 | # 1行目を編集 | ||
zend_extension = <配置したxdebug.soファイルのフルパス> | zend_extension = <配置したxdebug.soファイルのフルパス> | ||
| 100行目: | 120行目: | ||
xdebug.start_with_request=yes | xdebug.start_with_request=yes | ||
xdebug.dump_undefined=1 | xdebug.dump_undefined=1 | ||
xdebug. | xdebug.log="<出力したいログファイルのフルパス 例. /home/user/xdebug.log>" | ||
xdebug.remote_handler=dbgp | xdebug.remote_handler=dbgp | ||
xdebug. | xdebug.client_port=9003 ; 標準は9003番ポート | ||
xdebug.client_host=127.0.0.1 | |||
xdebug.idekey=VSCODE | xdebug.idekey=VSCODE | ||
<br> | <br> | ||
| 126行目: | 143行目: | ||
xdebug.idekey=VSCODE | xdebug.idekey=VSCODE | ||
<br> | <br> | ||
xdebug. | xdebug.iniファイルの設定を反映させるため、Apache2またはNginXを再起動する。<br> | ||
sudo systemctl restart apache2 | sudo systemctl restart apache2 | ||
または | または | ||
sudo systemctl restart | sudo systemctl restart nginx | ||
<br><br> | <br><br> | ||
| 324行目: | 341行目: | ||
最後に、PHPプロジェクトがデバッグできるかどうか確認する。<br> | 最後に、PHPプロジェクトがデバッグできるかどうか確認する。<br> | ||
<br><br> | <br><br> | ||
__FORCETOC__ | __FORCETOC__ | ||
[[カテゴリ: | [[カテゴリ:RHEL]][[カテゴリ:SUSE]][[カテゴリ:Web]] | ||