search
Homephp教程php手册windows7下安装php的php-ssh2扩展教程

因为想做一个往测试服务器传文件的需求,看到PHP支持ssh操作,所以整理了下安装过程,与大家分享下。

安装步骤

1. 下载 php extension ssh2
下载地址 http://windows.php.net/downloads/pecl/releases/ssh2/0.12/

根据自己PHP的版本去下载,我使用的是线程安全的,所以下载的是php_ssh2-0.12-5.4-ts-vc9-x86.zip

2. 解压完后,会有三个文件,libssh2.dll、php_ssh.dll、php_ssh2.pdb。

3. 将 php_ssh.dll、php_ssh2.pdb 放到你的 php 扩展目录下 php/ext/ 下。

4. 将libssh2.dll 复制到 c:/windows/system32 和 c:/windows/syswow64 各一份

5. php.ini中加入 extension=php_ssh2.dll

6. 重启apache,即可使用php执行ssh连接操作了。

查看phpinfo(),是否有显示php_ssh2扩展加载成功。

PHP测试代码

复制代码 代码如下:


$connection = ssh2_connect('192.168.255.128', 22);
ssh2_auth_password($connection, 'root', '123456');
ssh2_scp_send($connection, 'd:/tmp/test.txt', '/tmp/test.txt', 0644);

测试效果图:

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools