Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to install php-ssh2? #767

Closed
marknguyen85 opened this issue Dec 25, 2018 · 8 comments
Closed

how to install php-ssh2? #767

marknguyen85 opened this issue Dec 25, 2018 · 8 comments

Comments

@marknguyen85
Copy link

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
@yosifkit
Copy link
Member

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

@tianon
Copy link
Member

tianon commented Dec 27, 2018

Some clues:

  1. going to https://packages.debian.org/stretch/php-ssh2, we see the "Homepage" is https://pecl.php.net/package/ssh2, so pecl is the appropriate tool for installing this
  2. from that page:

    ssh2 1.0 and above is PHP 7 only. To install a version that is PHP 5 compatible you can run 'pecl install ssh2-0.13'

  3. looking at dependencies of https://packages.debian.org/stretch/php-ssh2, you likely need libssh2-1-dev installed in order to compile

I 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?)

@tianon tianon closed this as completed Dec 27, 2018
@marknguyen85
Copy link
Author

OK thanks for supoort

@yi-ge
Copy link

yi-ge commented Jan 1, 2019

# 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

@XedinUnknown
Copy link

Doesn't work for me

Unable to locate package libssh2-1-dev

@hornofj
Copy link

hornofj commented Apr 1, 2020

@yi-ge works for php5.4 too, thanks

@DMW007
Copy link

DMW007 commented Jun 24, 2020

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 

@thearyanahmed
Copy link

@DMW007 's solution worked for, tried on php7.4-fpm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants