i try install php-ssh2 but get error
apt install php-ssh2
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php-ssh2 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'php-ssh2' has no installation candidate
From the Docs on the Docker Hub, you have a couple options: https://github.com/docker-library/docs/tree/b10ac9706270ca71044eb75ccf7158c5124a5a36/php#e-package-php-xxx-has-no-installation-candidate
Some clues:
pecl is the appropriate tool for installing thislibssh2-1-dev installed in order to compileI was able to successfully install via the following:
FROM php:7.2-cli
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends libssh2-1-dev; \
pecl install ssh2-1.1.2; \
docker-php-ext-enable ssh2
It's _also_ worth noting that when trying this against PHP 7.3, I get _heaps_ of errors, so PHP 7.3 likely isn't supported by the ssh2 module yet. https://bugs.php.net/bug.php?id=77265#1544266627 mentions that it's likely fixed in Git via http://git.php.net/?p=pecl/networking/ssh2.git;a=commit;h=a8835aab2c15e794fce13bd927295719e384ad2d (hopefully with a release pending soonish?)
OK thanks for supoort
# ssh2
RUN apt-get install -y \
libssh2-1-dev
RUN cd /tmp && git clone https://git.php.net/repository/pecl/networking/ssh2.git && cd /tmp/ssh2 \
&& phpize && ./configure && make && make install \
&& echo "extension=ssh2.so" > /usr/local/etc/php/conf.d/ext-ssh2.ini \
&& rm -rf /tmp/ssh2
Doesn't work for me
Unable to locate package libssh2-1-dev
@yi-ge works for php5.4 too, thanks
I can't install the extension directly. But it works when downloading them manually like this:
FROM php:7.4-apache
RUN apt-get update && \
apt-get install -y gcc make libssh2-1-dev libssh2-1
RUN curl http://pecl.php.net/get/ssh2-1.2.tgz -o ssh2.tgz && \
pecl install ssh2 ssh2.tgz && \
docker-php-ext-enable ssh2 && \
rm -rf ssh2.tgz
RUN echo '<?php phpinfo();' > /var/www/html/i.php
Navigating to http://127.0.0.1/i.php I see
SSH2 support enabled
extension version 1.2
libssh2 version 1.8.0
@DMW007 's solution worked for, tried on php7.4-fpm.
Most helpful comment
I can't install the extension directly. But it works when downloading them manually like this:
Navigating to http://127.0.0.1/i.php I see