Ubuntu – How to install phpize for PHP 7+

php7software installation

I tried to install xdebug in my Ubuntu 16.04 with PHP7.0-fmp.

Inside the tailored tool it says:

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:      20151012
Zend Extension Api No:   320151012
If it does not, you are using the wrong phpize. 
Please follow this FAQ entry and skip the next step.

The FAQ only makes reference to php5-dev in order to install phpize.

Then following How to install and run phpize I found that php7.0-dev also should install

When I try run sudo apt-get install php7.0-dev I get the message:

php7.0-dev is already the newest version (7.0.8-0ubuntu0.16.04.2).
The following package was automatically installed and is no longer required:

That says that all the php7.0-dev package are already installed, but when I run phpize I get the following message:

root@ig:/usr/bin# phpize
Cannot find config.m4. 
Make sure that you run '/usr/bin/phpize' in the top level source directory of the module

I am already inside /usr/bin/ . How to run phpize in this scenario?

Best Answer

phpize for PHP7 is provided by the package php7.0-dev in Ubuntu 16.04. To install it open the terminal and type:

sudo apt install php7.0-dev  

phpize7.0 will be installed to /usr/bin/phpize7.0

To run it type:


Example: get version of phpize7.0:

phpize7.0 -v

In Ubuntu 17.10 php7.0-dev has been updated to php7.1-dev and phpize7.1 will be installed to /usr/bin/phpize7.1 . In Ubuntu 18.04 php7.0-dev has been updated to php7.2-dev. In Ubuntu 20.04+ php7.0-dev has been updated to php7.4-dev. php7.4-dev is the current package in Ubuntu 21.04, and the php 8 package hasn't been released in the Ubuntu 21.04 default repositories.

The phpize command is meant to be run at the top level of an extension source directory. This source directory should contain a file named config.m4. The config.m4 file for a PHP extension tells the UNIX build system what configure options your extension supports, what external libraries and includes you require, and what source files are to be compiled as part of it.