解決PHP 7.4安裝xdebug出現configure: error: rtnetlink.h is required, please...

GravityBox2202發表於2024-08-19

在PHP 7.4中安裝xdebug,出現"configure: error: rtnetlink.h is required, please make sure it is available by installing the correct package"的問題。
在使用sudo yum install kernel-devel 安裝完核心devel後還是報錯。
之後發現要安裝的是xdebug 3.3 的版本,但是xdebug 從3.2開始就已經不支援php 7.4了,雖然不知道是不是這個原因導致的,但是切換到3.1之後就可以正常安裝了。

This is the first release of Xdebug 3.2. This release adds support for PHP 8.2, and drops support for PHP 7.2 through PHP 7.4.

附:https://xdebug.org/announcements

同時附帶相關php.ini檔案以備查詢:
zend_extension=/usr/local/php7.4/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so
[xdebug]
xdebug.mode=debug,develop
xdebug.discover_client_host =true
xdebug.idekey="PHPSTORM"
;remote_host和remote_enable還有remote_port 已經變為 client_host client_port
xdebug.remote_host="192.168.182.1"
xdebug.remote_enable=1
;xdebug.remote_port =9003
;xdebug.remote_log =/tmp/xdebug.txt
;上面的remote選項已經失效,使用client
xdebug.client_host="192.168.182.1"
xdebug.clent_port=9003

xdebug.default_enable=0
xdebug.profiler_enable=0
xdebug.auto_trace=0
xdebug.coverage_enable=0
xdebug.remote_autostart=0

之前一直在使用php 5x的版本安裝和使用xdebug 2 ,在xdebug3中,有了開關 xdebug.mode=debug,develop ,預設為develop,不支援step,需要設定這個開關,
同時有一個 開關discover_client_host 需要注意,官方描述為:If enabled, Xdebug will first try to connect to the client that made the HTTP request. It checks the $_SERVER['HTTP_X_FORWARDED_FOR'] and $_SERVER['REMOTE_ADDR'] variables to find out which hostname or IP address to use.也就是說開啟開關後可以自動嘗試連線到發起請求的客戶端,而client_host 配置則為回退選項,也就是說如果無法連線則使用client_host的配置

相關文章