This article describes a problem that I ran into while developing an SSH application with PHP 8.0 on Windows 10 and the solution.

[Update 2023-08-01]

If you need php_ssh2.dll for PHP 8.2 on Windows/XAMPP, see my repository on GitHub. The repo also has a build for PHP 8.3 Beta1. The build for Beta2 is in testing.


  • Windows 10 Professional
  • XAMPP 8.0.6 – 2021-05-11
  • PHP 8.0.6

Example Code:

The problem line of code:

Generated this error:

I then checked the php.ini file to verify that the PHP extension extension=php_ssh2.dll was loaded. It was not.

I uncommented (enabled) the line and double-checked that php_ssh2.dll is located in the ext directory.

Then I received a different error:

Hmm, the DLL is there, but I do not know where that DLL came from or its version.

I opened the directory in Windows Explorer, right-clicked on the file, and selected Properties. The details tab showed the following:

The DLL Product version is 7.4.13.

Another method using PowerShell:

Which also shows the version as 7.4.13. PHP 8 probably needs a newer version.

Note: later in this article, I discover why. PHP has an Extension API version.


Going to the PECL download site for SSH2, I downloaded the latest package version, 1.3.1 for 64-bit Thread-Safe VS16. I chose VS16 because XAMPP version 8.0.6 specifies VS16. VS16 means the compiler packaged with Visual Studio 2019. [link]

Using the previous methods, I checked the version. SSH2 package version 1.3.1 contains DLL version 8.0.0. That should work. Downloaded the zip file, unpacked, and manually copied the DLL and PDB to the ext directory.

I then retried my program and success:

Detailed Information

XAMPP Version 8.0.6

Since the problem is on a system using XAMPP 8.0.6, I wanted to double-check that XAMPP did not have an issue. This means creating a new system and installing XAMPP.

I created a virtual machine with Windows 10 Professional and installed XAMPP 8.0.6. I then checked the C:\xampp\php\ext directory. The php_ssh2.dll was not found. This means someone manually copied the DLL from an older installation to my problem system.

XAMPP was not the source of the problem. Human error was most likely the source of the problem.

Detecting an extension

The following code will detect if an extension is installed:

However, this example does not prevent the PHP warning message if an extension is installed but does not load correctly:


To determine the php.ini file location, execute this command:

Note: If you have Apache configured with PHP, you will have two or more php.ini locations. One for the CLI and one for Apache. In my case, I install PHP-FPM, so there is a third.

For Apache, create a “not easy to find” PHP file with the following content:

Then load that file via URL in a web browser. The page will contain the file location that Apache is using for php.ini. Once you are finished remove the file. The output contains sensitive information.

Finding PHP INI Files

PHP supports many methods to declare where the php.ini file is located.

PHP Runtime Configuration

PHP supports the environment variable PHPRC. [link] Example for Windows:

Windows XAMPP:

On Windows, XAMPP uses the same location for the CLI and Apache.

XAMPP does use the directive PHPIniDir located in httpd-xampp.conf:

I use this command to search:


To search the file system for php.ini files, install the package mlocate (Ubuntu) and execute this command:

Note: installing the mlocate package creates a database of files and a cron job to update the database. If you do not want another background process running, use the find command example next.

On my Ubuntu 20.04 system with PHP 7.4 installed, a number of php.ini files are located:

Another command is which generates a similar output:

PHP Extension Directory

On my Windows XAMPP installation, the PHP extension directory is C:\xampp\php\ext. This location is configurable in the php.ini file.

PHP Extension Details

One item that I noticed with PHP 8.0 and 8.1. If you specify a module X in php.ini, the CLI will search for X and then for php_X.dll. This means that the php_ssh2.dll package can be specified as extension=ssh2

I found that php_ssh2.dll does not work with PHP 8.1 on Windows. In analyzing this problem, I noticed several items output by php -i:

  • PHP API => 20200930
  • PHP Extension => 20200930
  • Zend Extension => 420200930
  • Zend Extension Build => API420200930,TS,VS16
  • PHP Extension Build => API20200930,TS,VS16

I was not aware of an API version. The error details from PHP 8.1:

Warning: PHP Startup: ssh2: Unable to initialize module
Module compiled with module API=20200930
PHP compiled with module API=20210902

The string TS,VS16 means Thread-Safe Visual Studio 2019. That helps determine how to compile and build php_ssh2.dll.

Loading an extension at runtime

The CLI can load PHP extension with a command-line option:

This is useful while developing exception and error handling for extensions.

Unsolved Questions

Windows 10 Professional:

  • Is this DLL compatible with PHP 8.1 as that version is not mentioned?
    • No. Preliminary testing results in the error:
      • PHP Warning: PHP Startup: Unable to load dynamic library ‘php_ssh2.dll’ …
    • This GitHub Issue reports the same issue.

Ubuntu 20.04:

  • Validate LIBSSH2 support on Ubuntu 20.04 with PHP 8.0 and PHP8.1.

More Information

Article Tags


To install the LIBSSH2 bindings for PHP 8 on Windows 10, complete the following steps:

  • Download the correct versions from here.
  • Extract the package and copy the php_ssh2.dll and optionally php_ssh2.pdb to your PHP ext folder. On my system that is C:\xampp\php\ext.
  • Edit the php.ini and uncomment or add the line extension=php_ssh2.dll.

Software development is more than just writing code. We need to know how to configure systems and document those procedures. Also important, we need to write code or scripts to configure and test our environments. Nothing is worse than working long hours, releasing a great product that then becomes a customer support nightmare.

Photography Credits

I write free articles about technology. Recently, I learned about which provides free images. The image in this article is courtesy of Pixabay at Pexels.