📢 Webサイト閉鎖と移転のお知らせ
このWebサイトは2026年9月に閉鎖いたします。
新しい記事は移転先で追加しております。(旧サイトでは記事を追加しておりません)

 
(同じ利用者による、間の6版が非表示)
22行目: 22行目:
==== パッケージ管理システムからインストール ====
==== パッケージ管理システムからインストール ====
以下のコマンドを実行する。<br>
以下のコマンドを実行する。<br>
  # CentOS PHP 7.3
  # RHEL
  sudo yum install php73-pecl-xdebug.x86_64
  sudo dnf install php84-php-pecl-xdebug3.x86_64 # PHP 8.4の場合
   
                  php83-php-pecl-xdebug3.x86_64 # PHP 8.3の場合
  # CentOS PHP 7.4
                  php82-php-pecl-xdebug3.x86_64 # PHP 8.2の場合
  sudo yum install php74-pecl-xdebug.x86_64
                  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>
==== ソースコードからインストール ====
==== ソースコードからインストール ====
64行目: 67行目:
<br>
<br>
Xdebugをビルドおよびインストールする。<br>
Xdebugをビルドおよびインストールする。<br>
<br>
もし、<code>configure</code>スクリプトの実行に失敗する場合、Xdebugのビルドに必要なライブラリ等が不足している。<br>
もし、configureスクリプトの実行に失敗する場合、Xdebugのビルドに必要なライブラリやヘッダファイル等が不足していると考えられる。<br>
また、Xdebugのビルドにおいて、<u><code>--prefix</code>オプションが使用できないことに注意する。</u><br>
  mkdir xdebug-build && cd xdebug-build
  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
  make install
  または
  sudo make install
<br>
<br>
インストールしたxdebug.soファイルの場所は、各LinuxディストリビューションやPHPの環境により異なる。<br>
インストールしたxdebug.soファイルの場所は、各LinuxディストリビューションやPHPの環境により異なる。<br>
<br>
<br>
CentOSおよびSUSEにおいて、パッケージ管理システムからPHPをインストールした場合は、/usr/lib64/php<PHPのバージョン>/extensionsディレクトリに配置される。<br>
RHELおよびSUSEにおいて、パッケージ管理システムからPHPをインストールした場合は、/usr/lib64/php<PHPのバージョン>/extensionsディレクトリに配置される。<br>
ソースコードからPHPをインストールした場合は、/<PHPのインストールディレクトリ>/lib64/extensions/xxxディレクトリ等に配置される。<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>
  # CentOS
  # 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/php7/conf.d/xdebug.ini
  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_host</code>は、<code>xdebug.client_host</code>に置き換えられた。
: <code>xdebug.remote_port</code>は、<code>xdebug.client_port</code>に置き換えられた。
*: <code>xdebug.remote_port</code>は、<code>xdebug.client_port</code>に置き換えられた。
: <code>xdebug.remote_log</code>は、<code>xdebug.log</code>に置き換えられた。
*: <code>xdebug.remote_log</code>は、<code>xdebug.log</code>に置き換えられた。
これは Step Debugging以外のログメッセージも含まれる。
*: これは 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ファイルのフルパス>
106行目: 122行目:
  xdebug.log="<出力したいログファイルのフルパス  例. /home/user/xdebug.log>"
  xdebug.log="<出力したいログファイルのフルパス  例. /home/user/xdebug.log>"
  xdebug.remote_handler=dbgp
  xdebug.remote_handler=dbgp
xdebug.remote_mode=req
  xdebug.client_port=9003  ; 標準は9003番ポート
  xdebug.client_port=9003  ; 標準は9003番ポート
  xdebug.client_host=127.0.0.1
  xdebug.client_host=127.0.0.1
326行目: 341行目:
最後に、PHPプロジェクトがデバッグできるかどうか確認する。<br>
最後に、PHPプロジェクトがデバッグできるかどうか確認する。<br>
<br><br>
<br><br>


__FORCETOC__
__FORCETOC__
[[カテゴリ:RHEL]][[カテゴリ:SUSE]]
[[カテゴリ:RHEL]][[カテゴリ:SUSE]][[カテゴリ:Web]]