buy
Compile PHP Extensions

Overview

This guide will show you how you can compile(build) custom PHP Extensions.

Note:
We are going to show you example of mongodb extension with php81
You need to change path in the commands with your required PHP
you can refer the following PHP names to compile extensions for any other PHP's:
php56, php70, php71, php72, php73, php74, php80, php81, php82, php83

Steps

Download the source code of the extension.

wget --no-check-certificate https://pecl.php.net/get/mongodb-1.12.0.tgz

Extract the tgz file

tar -zxf mongodb-1.12.0.tgz

Go to extension source code and phpize the extension 

cd mongodb-1.12.0
/usr/local/apps/php81/apache2/bin/phpize

Compile and build the extension

./configure --with-php-config=/usr/local/apps/php81/bin/php-config
make all 
make install

After this steps you can find your extension at /usr/local/apps/php81/lib/extensions/no-debug-non-zts-20210902/

Note
Above path is for php81, for different PHP You can find extension installed in folder starting with no-debug-non-zts in /lib/extension/  folder.
Eg. For php74 extension will be installed in /usr/local/apps/php81/lib/extensions/no-debug-non-zts-20190902

You can follow the below guide to add newly compiled custom PHP extensions.
https://webuzo.com/docs/how-tos/custom-php-extensions/

    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list