6

If I run phpize -v then I get

Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718

If I open phpinfo then it shows a newer date

enter image description here

so my phpize is outdated.


This is the output of php -v:

PHP 7.4.21 (cli) (built: Jul  1 2021 16:09:41) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies

If I create a php info page and show it, then it shows PHP Version 7.4.21 too

How can I get phpize for php 7.4 ?

Black
  • 2,079
  • 1
    From what you posted, it looks like you have multiple versions of PHP. The PHP on the cli is a different version than what you have running under your web server. You should be able to find the correct version of phpize was installed with the different version of PHP, but you have not described how PHP was installed so I am unable to point you to where it would be. – GracefulRestart Sep 01 '21 at 16:25
  • No, if I run php -v then I get PHP 7.4.21, if I open a phpinfo site then I get PHP 7.4.21 too, see my updated question please. – Black Sep 02 '21 at 08:48

3 Answers3

4

To show all installed phpize versions installed using conformant packages on a debian-like system:

sudo update-alternatives --config phpize

You will see list of phpize versions

root@my-server:~# sudo update-alternatives --config phpize
There are 3 choices for the alternative phpize (providing /usr/bin/phpize).

Selection Path Priority Status

  • 0 /usr/bin/phpize.default 100 auto mode 1 /usr/bin/phpize.default 100 manual mode 2 /usr/bin/phpize8.1 81 manual mode 3 /usr/bin/phpize8.2 82 manual mode

Press <enter> to keep the current choice[*], or type selection number:

Hit required number.

PS: You have to install phpize for the different versions of PHP for it to appear above. To install for PHP 8.1 run sudo apt-get install php8.1-dev

symcbean
  • 5,540
3

Figured it out.

First I searched for php7:

apt-cache search php7.4

then I found php7.4-dev and installed it:

sudo apt install php7.4-dev

This installed phpize7.4 in /usr/bin

The last step is to set phpize to the new version with:

sudo update-alternatives --set phpize /usr/bin/phpize7.4

Now phpize -v outputs:

Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902
Black
  • 2,079
0

You also might need to change ./configure version :

phpize8.1
./configure --with-php-config=/usr/bin/php-config8.1 [...]

Context:

I had to compile a php module for php8.1 while I had many php version installed (8.0, 8.1, 8.2). So my main version was 8.2 and the module was not compiled correctly (for 8.2 instead of 8.1). Anyway, this does not answer author question, but it might help some people who met the same issue and are in the same case as me.

  • I don't see how this answers the question.  Can you explain?  Please do not respond in comments; [edit] your answer to make it clearer and more complete. – Scott - Слава Україні Dec 24 '22 at 01:51
  • Also, if this is an addition to the other answer, consider an edit there. – nohillside Dec 24 '22 at 06:37
  • This seems to be the start of an instruction to compile phpize from scratch, which isn't even remotely what the question asked about. – Shadur-don't-feed-the-AI Aug 17 '23 at 08:05
  • I had to compile a php module myself. So I met the same problem as the author. In addition to set a version to phpize, I also had to set a version to next step of building my module : set a version to php-config in the configure command. This does not answer author question, but it might help some people who met the same issue in the same case as me. – Guillaume S Aug 24 '23 at 16:19