
phpize Command in Linux
The phpize command in Linux prepares a PHP extension for compilation. It is commonly used to build and install a custom PHP extension from source by generating the configure script and other necessary build files for building a PHP extension.
Table of Contents
Here is a comprehensive guide to the options available with the phpize command â
- Installation of phpize Command in Linux
- Syntax of phpize Command
- phpize Command Options
- How to use phpize Command in Linux?
Installation of phpize Command in Linux
The phpize is a PHP-based tool that requires a PHP development package. To use phpize, the php-dev package must be installed on Linux. To install it on Ubuntu, Kali Linux, Raspberry Pi OS, Debian, and all Debian-based distributions, use the command given below −
sudo apt install php8.3-dev
To install it on Fedora, use the following command −
sudo dnf install php-devel
To verify the installation, check its binary path using the which command −
which phpize
Syntax of phpize Command
The syntax of the phpize command in Linux is as follows −
phpize [options]
The [options] field in the above syntax is used to specify various options (mentioned in the next section) to modify the commandâs response.
phpize Command Options
The options of the Linux phpize command are listed below −
Option | Description |
---|---|
--clean | Remove all created files |
--help | Displays usage information |
--version or -v | Displays API version information |
How to use phpize Command in Linux
In this section, the step-wise instructions for the example usage of the phpize command in Linux will be discussed.
- Using phpize Command
- Displaying API Information
- Cleaning up the Extension Directory for Rebuild
- Displaying Usage Help
For this example, letâs clone the Xdebug PHP extension source. The Xdebug extension is a popular debugging and profiling tool for PHP.
git clone https://github.com/xdebug/xdebug.git
The above command downloads the Xdebug extension source files from the official GitHub repository in the current working directory. To view it execute the ls command −

Using phpize Command
The step-by-step instructions to use phpize in Linux are listed below −
Step 1 − Navigate the Extension Source Directory
The first step is to navigate to the directory where extension source files are located. In this case, it is the xdebug directory.
cd /xdebug

Step 2 − Run phpize Command
In the source file directory, execute the phpize command −
sudo phpize

In order to prevent the permission denied error, use the sudo −
Step 3 − Configure the Build
To configure the build, execute the following command −
./configure --enable-xdebug

Step 4 − Make the Build
To make the build, run the make command in the same directory −
sudo make
The above command compiles the source code into binary files based on the instructions in the Makefile. The Makefile was generated earlier by the ./configure command.
Step 5 − Install the Compiled Binary
To install the compiled binary, use the following command −
sudo make install
Step 6 − Add Extension to php.ini File
To find the php.ini file, execute the following command −
php --ini

Look for Loaded Configuration File: /path/to/php.ini.
Open this ini file, using the nano editor −
sudo nano /etc/php/8.3/cli/php.ini
This path may differ depending on the PHP version and operating system setup.
Add the following line in the appropriate position −
zend_extension=xdebug.so

PHP requires zend_extension instead of an extension to load certain types of extensions, like Xdebug, because these extensions interact with PHP's internal Zend Engine. Simply using extension=xdebug.so will not work for Zend Engine extensions.
Now, restart the php8.x and apache2/nginx services −
sudo systemctl restart php8.3-fpm sudo systemctl restart apache2 sudo systemctl restart nginx
Step 7 − Verification
To verify the installation of the Xdebug extension, check the modules using the php command with the -m option. If the extension is installed the output will show the extension name.
php -m | grep xdebug

Displaying API Information
To display the API information, use the --version or -v option with the phpize command −
phpize -v

Cleaning up the Extension Directory for Rebuild
The --clean option for phpize is used to remove files generated during a previous run of phpize. Navigate to the extension source directory and execute the following command −
sudo phpize --clean

This is useful for cleaning up the directory if preparing to rebuild the extension or if leftover build artifacts are causing issues.
Displaying Usage Help
To display the usage help of the phpize command, use the --help option −
phpize --help
Conclusion
The phpize command in Linux is a utility used to prepare PHP extensions for compilation by generating the necessary configuration and build files. It is commonly employed when building and installing custom PHP extensions like Xdebug from source.
Proper installation of the php-dev package is required for using phpize. This tool supports various options, including cleaning build files, displaying API information, and showing usage help.