Skip to main content

Building a PHP Extension

On this site, you find a step-by-step guide on how to build a PHP Extension for a specific PHP Version.

Building a PHP Extension

  1. Make a backup of your instance.

  2. Install the dev package for the PHP Version.

apt update && apt -y install php8.3-dev
  1. Go to and search for the extension like ssh2:
  1. Download the tgz via cURL:
curl -O
  1. Extract the tgz:
tar xf ssh2-1.4.1.tgz
  1. phpize the extension:
cd ssh2-1.4.1
  1. Compile and build the extension:
./configure --with-php-config=/usr/bin/php-config8.3
make install
  1. Register the extension for CLI and FPM in the php.ini:


nano /etc/php/8.3/cli/php.ini

Add the following line at the end:


nano /etc/php/8.3/fpm/php.ini

Add the following line at the end:
  1. Restart the PHP-FPM service:
systemctl restart php8.3-fpm


After registering the PHP Extension, you can check if the extension is loaded for CLI and FPM correctly.


You can use grep to check if the extension is loaded:

php8.3 -m |grep 'ssh2' 

If you don't get an output, then the extension is NOT loaded.


To check if the extension is loaded for FPM, you can check the phpinfo.

  1. Create the file t.php in the root directory.

  2. Put the following content in the file:

  1. Open t.php in your browser and search for the extension.

If you don't find information about the extension, then it's NOT loaded.