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

 
(同じ利用者による、間の10版が非表示)
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>
==== ソースコードからインストール ====
==== ソースコードからインストール ====
55行目: 58行目:
<br>
<br>
===== Xdebugのインストール =====
===== Xdebugのインストール =====
まず、[https://xdebug.org/download Xdebugの公式Webサイト]に行き、Xdebugのソースコードをダウンロードする。<br>
まず、[https://xdebug.org/download Xdebugの公式Webサイト]にアクセスして、Xdebugのソースコードをダウンロードする。<br>
以下のコマンドを入力して解凍する。<br>
ダウンロードしたファイルを解凍する。<br>
  tar xf xdebug-<バージョン名>.tgz
  tar xf xdebug-<バージョン名>.tgz
cd xdebug-<バージョン名>
<br>
<br>
解凍したXdebugのディレクトリに移動し、phpizeコマンドを実行する。<br>
<code>phpize</code>コマンドを実行する。<br>
cd xdebug-<バージョン名>
  phpize
  phpize
<br>
<br>
次に、configureスクリプトを実行する。<br>
Xdebugをビルドおよびインストールする。<br>
インストール対象となるシステム特有の機能や情報を記述したMakefileを作成する。<br>
もし、<code>configure</code>スクリプトの実行に失敗する場合、Xdebugのビルドに必要なライブラリ等が不足している。<br>
もし、configureに失敗する場合、コンパイルに必要なライブラリやヘッダファイル等が不足していると考えられる。<br>
  mkdir xdebug-build && cd xdebug-build
<u><code>--prefix</code>オプションは使用できないので注意すること。</u><br>
  ./configure --enable-xdebug
../configure \
<br>
              --enable-xdebug    \
Xdebugのソースコードをコンパイルする。<br>
              --enable-xdebug-dev \  # 任意
              --prefix=<PHPのインストールディレクトリ> # PHPを任意のディレクトリにインストールしている場合等に指定する
  make -j $(nproc)
  make -j $(nproc)
make install
または
sudo make install
<br>
<br>
Xdebugをインストールする。<br>
インストールしたxdebug.soファイルの場所は、各LinuxディストリビューションやPHPの環境により異なる。<br>
<u>必ず、スーパーユーザ権限で実行すること。</u><br>
sudo make install
<br>
<br>
インストールしたxdebug.soファイルは、/usr/lib64/php7/extensionsディレクトリに配置される。<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>
  # 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_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.remote_log="/tmp/xdebug.log"
  xdebug.log="<出力したいログファイルのフルパス  例. /home/user/xdebug.log>"
xdebug.remote_host=localhost
xdebug.remote_port=9003
  xdebug.remote_handler=dbgp
  xdebug.remote_handler=dbgp
  xdebug.remote_mode=req
  xdebug.client_port=9003 ; 標準は9003番ポート
  xdebug.client_port=9000
  xdebug.client_host=127.0.0.1
  ;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.iniファイルの設定を反映させるため、Apache2またはNgineXを再起動する。<br>
xdebug.iniファイルの設定を反映させるため、Apache2またはNginXを再起動する。<br>
  sudo systemctl restart apache2
  sudo systemctl restart apache2
  または
  または
  sudo systemctl restart nginex
  sudo systemctl restart nginx
<br><br>
<br><br>


324行目: 341行目:
最後に、PHPプロジェクトがデバッグできるかどうか確認する。<br>
最後に、PHPプロジェクトがデバッグできるかどうか確認する。<br>
<br><br>
<br><br>


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