我最近在我的Ubuntu 20.04服务器上安装了PHP 8.0,我试图让Xdebug与它一起工作。我已经按照https://xdebug.org/wizard:
的指示安装了它。Installation Wizard
Summary
Xdebug installed: no
Server API: Command Line Interface
Windows: no
Zend Server: no
PHP Version: 8.0.0
Zend API nr: 420200930
PHP API nr: 20200930
Debug Build: no
Thread Safe Build: no
OPcache Loaded: yes
Configuration File Path: /etc/php/8.0/cli
Configuration File: /etc/php/8.0/cli/php.ini
Extensions directory: /usr/lib/php/20200930
Instructions
Download xdebug-3.0.2.tgz
Install the pre-requisites for compiling PHP extensions.
On your Ubuntu system, install them with: apt-get install php-dev autoconf automake
Unpack the downloaded file with tar -xvzf xdebug-3.0.2.tgz
Run: cd xdebug-3.0.2
Run: phpize (See the FAQ if you don't have phpize).
As part of its output it should show:
Configuring for:
...
Zend Module Api No: 20200930
Zend Extension Api No: 420200930
If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.
Run: ./configure
Run: make
Run: cp modules/xdebug.so /usr/lib/php/20200930
Edit /etc/php/8.0/cli/php.ini and add the line
zend_extension = /usr/lib/php/20200930/xdebug.so
Make sure that zend_extension = /usr/lib/php/20200930/xdebug.so is below the line for OPcache.
Please also update php.ini files in adjacent directories, as your system seems to be configured with a separate php.ini file for the web server and command line.
但我得到这个错误时做php -v
:
Xdebug requires Zend Engine API version 320190902.
The Zend Engine API version 420200930 which is installed, is newer.
Contact Derick Rethans at https://xdebug.org/docs/faq#api for a later version of Xdebug.
当我运行phpize时,我得到这样的输出:
Configuring for:
PHP Api Version: 20190902
Zend Module Api No: 20190902
Zend Extension Api No: 320190902
所以我不确定我在这里需要做什么。为什么我不能使用正确的Zend API版本?
Ubuntu报告我有最新版本的autoconf
, automake
和php-dev
我也有同样的问题。经过一番调查,我意识到问题的原因是编译过程中假设的配置路径指向全局php-config(另一个php版本)。所以我只需要运行带有标志(在我的例子中是Xampp)的编译:
./configure --with-php-config=/opt/lampp/bin/php-config
接下来的步骤和你做的一样,而且效果很好。