为 Zephir 解析器将 PHP 7.4 升级到 PHP 8.0(无法初始化模块)

问题描述 投票:0回答:0

php -v
产生以下输出:

PHP 8.0.28 (cli) (built: Feb 14 2023 18:32:57) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.28, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.28, Copyright (c), by Zend Technologies

ls -l /etc/alternatives/*php*
产生以下输出:

lrwxrwxrwx 1 root root 15 Apr 17 20:51 /etc/alternatives/php -> /usr/bin/php8.0
lrwxrwxrwx 1 root root 22 Apr 17 20:51 /etc/alternatives/php-config -> /usr/bin/php-config8.0
lrwxrwxrwx 1 root root 38 Apr 17 20:51 /etc/alternatives/php-config.1.gz -> /usr/share/man/man1/php-config8.0.1.gz
lrwxrwxrwx 1 root root 31 Apr 17 20:51 /etc/alternatives/php.1.gz -> /usr/share/man/man1/php8.0.1.gz
lrwxrwxrwx 1 root root 18 Apr 17 20:51 /etc/alternatives/phpize -> /usr/bin/phpize8.0
lrwxrwxrwx 1 root root 34 Apr 17 20:51 /etc/alternatives/phpize.1.gz -> /usr/share/man/man1/phpize8.0.1.gz

根据 Github 上的文档,我运行以下命令:

/etc/alternatives/phpize
./configure --with-php-config=/etc/alternatives/php-config
make
make install

这会在

./modules
目录中创建 SO,并将其放入
/usr/lib/php/20200930
目录中。

然后我

vim /etc/php/8.0/cli/php.ini
并在保存和关闭之前添加
extension=zephir_parser.so

运行

php -v
现在给我:

PHP Warning:  PHP Startup: zephir_parser: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930
These options need to match
 in Unknown on line 0
PHP 8.0.28 (cli) (built: Feb 14 2023 18:32:57) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.28, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.28, Copyright (c), by Zend Technologies

我在目标机器上安装了 PHP 7.4,但它没有获取 PHP 8 配置?任何帮助表示赞赏。

更新:

make install
的截断输出:

libtool: install: cp ./.libs/zephir_parser.so /home/someuser/zephir

/php-zephir-parser/modules/zephir_parser.so
libtool: install: cp ./.libs/zephir_parser.lai /home/someuser/zephir/php-zephir-parser/modules/zephir_parser.la
libtool: finish: PATH="/root/.nvm/versions/node/v18.7.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin" ldconfig -n /home/someuser/zephir/php-zephir-parser/modules
[...]
Installing shared extensions:     /usr/lib/php/20200930/
Installing header files:          /usr/include/php/20200930/

即使将绝对路径放入 SO 也会抛出相同的构建版本错误:

extension=/usr/lib/php/20200930/zephir_parser.so

php -v

PHP Warning:  PHP Startup: zephir_parser: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930
These options need to match
 in Unknown on line 0
PHP 8.0.28 (cli) (built: Feb 14 2023 18:32:57) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.28, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.28, Copyright (c), by Zend Technologies
php ubuntu php-extension php-8 zephir
© www.soinside.com 2019 - 2024. All rights reserved.