Hướng dẫn brew install php ssh2

This is a ✨special✨ repository containing the organization level discussions for Homebrew. Everything posted here will also be visible at the organization level.

Replies: 3 suggested answers 18 replies

Add heading textAdd bold text, Add italic text,

Add a quote, Add code,

Add a link,

Add a bulleted list, Add a numbered list, Add a task list,

Directly mention a user or teamReference an issue or pull request

Add heading textAdd bold text, Add italic text, Add a bulleted list, Add a numbered list, Add a task list,

reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji

I finally found a solution on MacOS Mohave. I have PHP 7.3 installed by Homebrew:

brew install php
brew install libssh2

Install development version of ssh2 pecl extension from the latest sources:

cd ~/Downloads
git clone https://github.com/php/pecl-networking-ssh2.git
cd pecl-networking-ssh2
phpize
./configure
make
make install

Enable extension in php.ini. You can use TextEdit:

open -e /usr/local/etc/php/7.3/php.ini

Add extension="ssh2.so" to the beginning of the file and save.

Test the result:

php -i | grep 'libssh2 version'

You should see

libssh2 version => 1.10.0

-- EDIT for Apple silicon (M1)

Homebrew uses different path on Apple silicon machines and ./configure command fails with error: "checking for ssh2 files in default path... not found". I resolved this with setting custom path:

./configure --with-ssh2=/opt/homebrew/opt/libssh2

We have already discussed about how to install and configure SSH2 extension in XAMPP in Linux System, same process will configure in your PHP.

Nội dung chính

  • Introduction
  • What is php-pecl-ssh2
  • Install php-pecl-ssh2 on CentOS 7 Using yum
  • Install php-pecl-ssh2 on CentOS 7 Using dnf
  • How To Uninstall php-pecl-ssh2 on CentOS 7
  • php-pecl-ssh2 Package Contents on CentOS 7

Step 1 : Before start, we need to update and install the necessary packages for  build/install ssh2 extension

#  yum update

#  yum install  make gcc  libssh2  php-devel php-pearlibssh2-devel

Step 2 : Install ssh2 extension using pecl command for  auto detect and download once hit enter,

#  pecl install -f ssh2


downloading ssh2-0.12.tgz ...
Starting to download ssh2-0.12.tgz (26,223 bytes)
.........done: 26,223 bytes
6 source files, building
running: phpize
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
libssh2 prefix? [autodetect] :
...
.....
Build process completed successfully
Installing '/usr/lib64/php/modules/ssh2.so'
install ok: channel://pecl.php.net/ssh2-0.12
configuration option "php_ini" is not set to php.ini location
You should add "extension=ssh2.so" to php.ini

Step 3 : Once the package has been installed in your system, we need to configure the extension to PHP (php.ini  or ssh2.ini)

# echo "extension=ssh2.so" >  /etc/php.d/ssh2.ini

or

# echo "extension=ssh2.so"  > /etc/php.ini

Step 4 : Finally restart your web server

# service restart httpd.service

Now, check the module whether is configure with PHP,

# php -m | grep ssh2

ssh2

Also can  check in your phpinfo();

I am not able to install ssh2 in centos.

I using apache2 and PHP 7.3

I using below command and giving me error as below

yum install gcc php-devel libssh2 libssh2-devel php-pear make
pecl install -f ssh2

but it's showing me below error

No package php-devel available.
No package php-pear available.

please tell me what I missing.

asked Dec 19, 2019 at 6:15

1

In CentOS 7, what about enabling EPEL and then yum install php-pecl-ssh2

EDIT: Looks like CentOS 7 includes PHP 5 by default. The ssh2 page (https://pecl.php.net/package/ssh2) says:

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'

answered Dec 21, 2019 at 7:24

1

In this tutorial we learn how to install php-pecl-ssh2 on CentOS 7. php-pecl-ssh2 is Bindings for the libssh2 library

Introduction

In this tutorial we learn how to install php-pecl-ssh2 on CentOS 7.

What is php-pecl-ssh2

Bindings to the functions of libssh2 which implements the SSH2 protocol. libssh2 is available from http

We can use yum or dnf to install php-pecl-ssh2 on CentOS 7. In this tutorial we discuss both methods but you only need to choose one of method to install php-pecl-ssh2.

Install php-pecl-ssh2 on CentOS 7 Using yum

Update yum database with yum using the following command.

After updating yum database, We can install php-pecl-ssh2 using yum by running the following command:

sudo yum -y install php-pecl-ssh2

Install php-pecl-ssh2 on CentOS 7 Using dnf

If you don’t have dnf installed you can install dnf first. Update yum database with dnf using the following command.

After updating yum database, We can install php-pecl-ssh2 using dnf by running the following command:

sudo dnf -y install php-pecl-ssh2

How To Uninstall php-pecl-ssh2 on CentOS 7

To uninstall only the php-pecl-ssh2 package we can use the following command:

sudo dnf remove php-pecl-ssh2

php-pecl-ssh2 Package Contents on CentOS 7

/etc/php.d/ssh2.ini
/usr/lib64/php/modules/ssh2.so
/usr/share/doc/php-pecl-ssh2-0.12
/usr/share/doc/php-pecl-ssh2-0.12/LICENSE
/usr/share/doc/php-pecl-ssh2-0.12/README
/var/lib/pear/pkgxml/php-pecl-ssh2.xml

References

  • php-pecl-ssh2 website

Summary

In this tutorial we learn how to install php-pecl-ssh2 on CentOS 7 using yum and dnf.