Php ssh2 extension install

How to Install the PHP SSH2 Extension

In the examples shown, replace «X.Y» with your app’s PHP version (for example, «7.4» or «8.2»). To install a PECL extension for multiple PHP versions, repeat the PECL extension installation for each PHP version.

The SSH2 extension provides functions for accessing remote machines using the secure SSH and SFTP protocols.

Installing the SSH2 Extension on PHP 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, or 8.2

Note: The SSH2 extension’s support for PHP 7.x and 8.x is currently in beta.

To install this extension on PHP 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, or 8.2 SSH in as root and run the following commands on your server:

sudo apt-get -y install gcc make autoconf libc-dev pkg-config sudo apt-get -y install libssh2-1-dev sudo peclX.Y-sp install ssh2-beta

Once installed, create a configuration file for the extension and restart PHP.

sudo bash -c "echo extension=ssh2.so > /etc/phpX.Y-sp/conf.d/ssh2.ini" sudo service phpX.Y-fpm-sp restart

Installing the SSH2 Extension on PHP 5

To install this extension on PHP 5.6, SSH in as root and run the following on your server:

sudo apt-get install gcc make autoconf libc-dev pkg-config sudo apt-get install libssh2-1-dev sudo pecl5.6-sp install ssh2

Once installed, create a configuration file for the extension and restart PHP.

sudo bash -c "echo extension=ssh2.so > /etc/php5.6-sp/conf.d/ssh2.ini" sudo service php5.6-fpm-sp restart

Verifying the Installation

You can verify the SSH2 extension is installed with the command:

If SSH2 is installed correctly, you will see the following:

/etc/phpX.Y-sp/conf.d/ssh2.ini, Registered PHP Streams => https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, zip, phar, ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp ssh2 SSH2 support => enabled libssh2 version => 1.4.3 banner => SSH-2.0-libssh2_1.4.3

Uninstalling the SSH2 Extension

To uninstall this extension, as root run the commands:

sudo rm /etc/phpX.Y-sp/conf.d/ssh2.ini sudo peclX.Y-sp uninstall ssh2

Next, restart PHP-FPM with the command:

sudo service phpX.Y-fpm-sp restart

Источник

Моя Россыпь

В CentOS8 по умолчанию устанавливается версия php – 7.2.
Данная версия языка php не содержит готового пакета расширения ssh2 в репозитариях CentOS8. Более того расширение не поддерживается официально для php7. В связи с этим нет возможности использовать директивы ssh2_connect, ssh2_exec, ssh2_scp_send в программах на php7.

Это ограничение можно обойти, установив расширение вручную.
1) Подготовим систему для сборки расширения ssh2
# yum install gcc php-devel libssh2 libssh2-devel

Читайте также:  Php ini mysql extension problem

2) Скачиваем и собираем расширение
# cd /usr/src
# git clone https://github.com/php/pecl-networking-ssh2.git
# cd pecl-networking-ssh2
# phpize
# ./configure
# make
Сборка завершается сообщением:
———————————————————————-
Libraries have been installed in:
/usr/src/pecl-networking-ssh2/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the ‘-LLIBDIR’
flag during linking and do at least one of the following:
— add LIBDIR to the ‘LD_LIBRARY_PATH’ environment variable
during execution
— add LIBDIR to the ‘LD_RUN_PATH’ environment variable
during linking
— use the ‘-Wl,-rpath -Wl,LIBDIR’ linker flag
— have your system administrator add LIBDIR to ‘/etc/ld.so.conf’

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
———————————————————————-
3) Устанавливаем собранный пакет
# make install
Результат:
Installing shared extensions: /usr/lib64/php/modules/

4) Информацию о новом модуле нужно задать в директории /etc/php.d
Создаем файл и заносим в него информацию о расширении:
# touch /etc/php.d/40-ssh2.ini
# nano /etc/php.d/40-ssh2.ini
Вписываем туда:
extension=ssh2

5) Проверить результат можно командой:
# php -i |grep ssh2
Для применения настроек в apache, web-сервер нужно перезагрузить

Источник

Php ssh2 extension install

Installation For Centos 5.11 x86_64

rpm -K rpmforge-release-0.5.3-1.el5.rf.*.rpm

rpm -i rpmforge-release-0.5.3-1.el5.rf.*.rpm

2. yum install gcc php-devel php-pear libssh2 libssh2-devel
3. pecl install -f ssh2
4. Enable extension from php.ini configuration

Steps for installing the extension package on Debian systems:

> sudo apt-get install libssh2-php
> sudo /etc/init.d/apache2 restart

The SSH2 binary for Windows (php_ssh2.dll) can be found here: http://pecl.php.net/package/ssh2/1.1.2/windows

[Editor’s note: unless you have special demands, use the appropriate deps package from .]

SSH2 for Windows is not available from the authors of the extension. But compiled binaries are available from the Apache Lounge (which is recommended by the php.net website too).

This binaries contain a lot (maybe even all?) for Windows compiled PHP extensions, like the SSH2 extension.

Please note that it is also highly recommended to use their Windows binary builds for the Apache HTTP server from here: https://www.apachelounge.com/download/

Older versions can be choosen from the left menu (VC11, VC10, etc.) if required.

php.net also recommends to use the binary builds from the Apache Lounge.

Maybe this helps developers, who work with Windows and can’t find or compile some extensions themself.

Steps for installing on CentOS Linux 7

After having a full webserver running, install packages libssh2.x86_64 and php-pecl-ssh2.x86_64

1. yum install libssh2.x86_64 php-pecl-ssh2.x86_64
2. systemctl restart httpd.service

on linux debian like (ubuntu) a simple install will also load ‘libssh2-1’
$ sudo apt-get update && sudo apt-get install php-ssh2

$ sudo apache2ctl graceful
should make it usable

use phpinfo() function, some sections are now showing additional «ssh2» parts:
— Intro section with new items for «ssh2»
— — Additional .ini files parsed
— — Registered PHP Streams
— ssh2 (new section)
— — showing «SSH2 support — enabled»

Читайте также:  Xpath примеры к html

Using PECL it must be specified the channel, since the beta version has to be choosen instead of stable one:

$ pecl install ssh2 channel://pecl.php.net/ssh2-version

Steps for installing the extension package on Ubuntu 14.04.

Very similar to dreadwestern at gmail dot com recipe, but enable ssh2 in PHP:

> sudo apt-get install libssh2-php
> php5enmod ssh2
> sudo /etc/init.d/apache2 restart

Since version 0.12 (released 2012-10-15) there is a binary version for Windows.

I tested it with PHP 5.5.29 (32-bit, thread-safe) on my Windows 7 machine.

Installing on Ubuntu 14.0.4

sudo pecl channel-update pecl.php.net
sudo apt-get install libssh2-1-dev
sudo pecl install -a ssh2-0.12
echo ‘extension=ssh2.so’ | sudo tee /etc/php5/mods-available/ssh2.ini > /dev/null
sudo php5enmod ssh2

On centos 8 and rockylinux:

Installing this module for use with CentOS 5. or 6.?

1. Install your favorite PHP RPM packages. Make sure that one of your favorite packages is pear, so pecl gets installed in-tow.

2. Find and install *RPMS* of libssh2 of a version >= 1.2, get both the base lib package (libssh2-1.2.*.rpm) and the devel package that includes headers (libssh2-devel-1.2.*.rpm) of the EXACT SAME VERSION. Finding these packages took a few minutes of googling, and I invite an editor that has a trusted source for these to attach URLs as appropriate. (Yes, the version below is ancient)

# rpm -ivh libssh2-1.2.6-1.el5.rf.x86_64.rpm libssh2-devel-1.2.6-1.el5.rf.x86_64.rpm

3. Install the PHP module via pecl
# pecl install ssh2-0.12

4. Make PHP see the newly-installed extension
# echo «extension=ssh2.so» > /etc/php.d/ssh2.ini

To help someone avoid the headaches I did for a week. SSH2 functions have problems with the ssh2-beta & libssh2-0.18 even after patching with said patches on the internet.

ssh_exec will work fine
ssh2_shell will not work

In order to use ssh2_shell I had to roll back to libssh2-0.14 in order to get ssh2_shell function to work properly

Just a little note: when compiling this package after modifying the ssh2.c, do not use pecl build as it will not create an ssh2.so file (although it says it succeeded), use:

you then need to copy the ssh2.so file into your extension dir if it didn’t do so already.

Источник

How to Install the PHP SSH2 Extension

In the examples shown, replace «X.Y» with your app’s PHP version (for example, «5.4» or «7.1»). To install a PECL extension for multiple PHP versions, repeat the PECL extension installation for each PHP version.

The SSH2 extension provides functions for accessing remote machines using the secure SSH and SFTP protocols.

Installing the SSH2 Extension on PHP 5

To install this extension on PHP 5.4, 5.5, or 5.6, SSH in as root and run the following on your server:

sudo apt-get install gcc make autoconf libc-dev pkg-config sudo apt-get install libssh2-1-dev sudo pecl5.X-sp install ssh2

Once installed, create a configuration file for the extension and restart PHP.

sudo bash -c "echo extension=ssh2.so > /etc/php5.X-sp/conf.d/ssh2.ini" sudo service php5.X-fpm-sp restart

Installing the SSH2 Extension on PHP 7

Note: The SSH2 extension’s support for PHP 7 is currently in alpha.

To install this extension on PHP 7.0 or 7.1, SSH in as root and run the following on your server:

sudo apt-get install gcc make autoconf libc-dev pkg-config sudo apt-get install libssh2-1-dev sudo pecl7.X-sp install ssh2-alpha

Once installed, create a configuration file for the extension and restart PHP.

sudo bash -c "echo extension=ssh2.so > /etc/php7.X-sp/conf.d/ssh2.ini" sudo service php7.X-fpm-sp restart

Verifying the Installation

You can verify the SSH2 extension is installed with the command:

Читайте также:  Print one decimal python

If SSH2 is installed correctly, you will see the following:

/etc/phpX.Y-sp/conf.d/ssh2.ini, Registered PHP Streams => https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, zip, phar, ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp ssh2 SSH2 support => enabled libssh2 version => 1.4.3 banner => SSH-2.0-libssh2_1.4.3

Источник

How To Install php-ssh2 on Ubuntu 20.04

In this tutorial we learn how to install php-ssh2 on Ubuntu 20.04.

What is php-ssh2

Provides PHP bindings to the functions of libssh2 which implements the SSH2 protocol.

WARNING: The PHP 7.0 is an unreleased git snapshot of current ssh2 that implements support for PHP 7.0. USE WITH CAUTION! Description-md5: 8adc0199b55f9ddf168edba900604566

There are three ways to install php-ssh2 on Ubuntu 20.04. We can use apt-get , apt and aptitude . In the following sections we will describe each method. You can choose one of them.

Install php-ssh2 Using apt-get

Update apt database with apt-get using the following command.

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

sudo apt-get -y install php-ssh2 

Install php-ssh2 Using apt

Update apt database with apt using the following command.

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

sudo apt -y install php-ssh2 

Install php-ssh2 Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

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

sudo aptitude -y install php-ssh2 

How To Uninstall php-ssh2 on Ubuntu 20.04

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

sudo apt-get remove php-ssh2 

Uninstall php-ssh2 And Its Dependencies

To uninstall php-ssh2 and its dependencies that are no longer needed by Ubuntu 20.04, we can use the command below:

sudo apt-get -y autoremove php-ssh2 

Remove php-ssh2 Configurations and Data

To remove php-ssh2 configuration and data from Ubuntu 20.04 we can use the following command:

sudo apt-get -y purge php-ssh2 

Remove php-ssh2 configuration, data, and all of its dependencies

We can use the following command to remove php-ssh2 configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge php-ssh2 

References

Summary

In this tutorial we learn how to install php-ssh2 package on Ubuntu 20.04 using different package management tools: apt, apt-get and aptitude.

Источник

Оцените статью