Search code examples
phplinuxazureazure-web-app-servicedebian

How to install PHP Extension php-ssh2 on Azure App Service (PHP 8.2 / Linux)?


Does anyone know how to install the PHP extension "php-ssh2" on an Azure App Service with PHP version 8.2 and Linux OS?

I tried installing the extension from a different repository, but unfortunately this does not work ([Not candidate version]).

Thank you in advance,


Solution

  • Check the below steps to install the SSH2 extension in Azure Linux App Service.

    Open the KUDU Console:

    https://YourApp.scm.azurewebsites.net/webssh/host
    

    enter image description here

    My PHP Version:

    enter image description here

    • Run the below command to install the SSH2 version.
    apt-get update
    apt-get install -y libssh2-1-dev
    

    enter image description here

    • Run pear config-show command to see the paths of the directories.

    enter image description here

    • Run pecl install https://pecl.php.net/get/ssh2-1.4.tgz command to install the ssh2 zip file.

    • You can see the downloaded ssh2 file in /tmp/pear/download directory

    • Next run the below commands

    cd  /tmp/pear/download/
    tar -xzf ssh2-1.4.tgz
    cd ssh2-1.4
    phpize
    ./configure
    make
    make install
    

    enter image description here

    • Now you can see modules folder is created in /tmp/pear/download/ssh2-1.4 directory.

    • modules folder contains the ssh2.so file.

    enter image description here

    • Now we need to move this file from download to extension folder /usr/local/lib/php/extensions/no-debug-non-zts-20220829 folder
    mv /tmp/pear/download/ssh2-1.4/modules/ssh2.so /usr/local/lib/php/extensions/no-debug-non-zts-20220829
    

    enter image description here

    • Run the php -m to check the extensions.

    enter image description here