: This article describes how to install the ssh2 extension when php accesses sftp in the OSX system. if you are interested in the PHP Tutorial, refer to it. Andy @ AndyMacBookPro:/usr/local/src $ php-v
PHP 5.4.40 (cli) (built: May 3 2015 22:07:42)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
With Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
Andy @ AndyMacBookPro:/usr/local/src $ brew search ssh2
Libssh2 php53-ssh2 php54-ssh2 php55-ssh2 php56-ssh2
^ C
/Usr/local/Library/brew. rb: Interrupt
Andy @ AndyMacBookPro:/usr/local/src $ brew install php54-ssh2
==> Installing dependencies for php54-ssh2: libpng, gettext, icu4c, php54
==> Installing php54-ssh2 dependency: libpng
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libpng-1.6.
######################################## ################################ 100.0%
=> Pouring libpng-1.6.13.mavericks.bottle.tar.gz
? /Usr/local/Cellar/libpng/1.6.13: 17 files, 1.2 M
==> Installing php54-ssh2 dependency: gettext
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/gettext-0.1
######################################## ################################ 100.0%
=> Pouring gettext-0.19.2.mavericks.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into/usr/local.
Mac OS X provides similar software, and installing this software in
Parallel can cause all kinds of trouble.
OS X provides the BSD gettext library and some software gets confused if both are in the library path.
Generally there are no consequences of this for you. If you build your
Own software and it requires this formula, you'll need to add to your
Build variables:
LDFLAGS:-L/usr/local/opt/gettext/lib
CPPFLAGS:-I/usr/local/opt/gettext/include
==> Summary
? /Usr/local/Cellar/gettext/0.19.2: 1920 files, 18 M
==> Installing php54-ssh2 dependency: icu4c
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/icu4c-53.1.
######################################## ################################ 100.0%
=> Pouring icu4c-53.1.mavericks.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into/usr/local.
Conflicts; see: https://github.com/Homebrew/homebrew/issues/issue/167
Generally there are no consequences of this for you. If you build your
Own software and it requires this formula, you'll need to add to your
Build variables:
LDFLAGS:-L/usr/local/opt/icu4c/lib
CPPFLAGS:-I/usr/local/opt/icu4c/include
==> Summary
? /Usr/local/Cellar/icu4c/53.1: 241 files, 57 M
==> Installing php54-ssh2 dependency: php54
==> Downloading http://www.php.net/get/php-5.4.32.tar.bz2/from/this/mirror
######################################## ################################ 100.0%
Warning: Backing up all known pear. conf and. pearrc files
Warning: If you have a pre-existing pear install outside
Of homebrew-php, or you are using a non-standard
Pear. conf location, installation may fail.
==>./Configure -- prefix =/usr/local/Cellar/php54/5.4.32 -- localstatedir =/usr/loc
==> Make
==> Make install
==>/Usr/local/Cellar/php54/5.4.32/bin/pear config-set php_ini/usr/local/etc/ph
==> Caveats
To enable PHP in Apache add the following to httpd. conf and restart Apache:
LoadModule php5_module/usr/local/opt/php54/libexec/apache2/libphp5.so
The php. ini file can be found in:
/Usr/local/etc/php/5.4/php. ini
???? PEAR ????
If PEAR complains about permissions, 'fix' the default PEAR permissions and config:
Chmod-R ug + w/usr/local/Cellar/php54/5.4.32/lib/php
Pear config-set php_ini/usr/local/etc/php/5.4/php. ini
???? Extensions ????
If you are having issues with custom extension compiling, ensure that
You are using the brew version, by placing/usr/local/bin before/usr/sbin in your PATH:
PATH = "/usr/local/bin: $ PATH"
PHP54 Extensions will always be compiled against this PHP. Please install them
Using -- without-homebrew-php to enable compiling against system PHP.
???? Php cli ????
If you wish to swap the PHP you use on the command line, you should add the following ~ /. Bashrc,
~ /. Zshrc ,~ /. Profile or your shell's equivalent configuration file:
Export PATH = "$ (brew -- prefix homebrew/php/php54)/bin: $ PATH"
To have launchd start php54 at login:
Ln-sfv/usr/local/opt/php54/*. plist ~ /Library/LaunchAgents
Then to load php54 now:
Launchctl load ~ /Library/LaunchAgents/homebrew. mxcl. php54.plist
==> Summary
? /Usr/local/Cellar/php54/5.4.32: 489 files, 38 M, built in 7.6 minutes
==> Installing php54-ssh2 dependency: libssh2
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libssh2-1.4
######################################## ################################ 100.0%
=> Pouring libssh2-1.4.3_1.mavericks.bottle.tar.gz
? /Usr/local/Cellar/libssh2/1.4.3 _ 1: 177 files, 1.3 M
==> Installing php54-ssh2
==> Downloading http://pecl.php.net/get/ssh2-0.12.tgz
######################################## ################################ 100.0%
==> PHP_AUTOC/usr/local/opt/autoconf/bin/autoconf "PHP_AUTOHEADER ="/usr/loc
==>./Configure -- prefix =/usr/local/Cellar/php54-ssh2/0.12 -- with-php-c >=> make
==> Caveats
To finish installing ssh2 for PHP 5.4:
*/Usr/local/etc/php/5.4/conf. d/ext-ssh2.ini was created,
Do not forget to remove it upon extension removal.
* Validate installation via one of the following methods:
*
* Using PHP from a webserver:
*-Restart your webserver.
*-Write a PHP page that CILS "phpinfo ();"
*-Load it in a browser and look for the info on the ssh2 module.
*-If you see it, you have been successful!
*
* Using PHP from the command line:
*-Run "php-I" (command-line "phpinfo ()")
*-Look for the info on the ssh2 module.
*-If you see it, you have been successful!
==> Summary
? /Usr/local/Cellar/php54-ssh2/0.12: 3 files, 72 K, built in 10 seconds
Andy @ AndyMacBookPro:/usr/local/src $
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.
The above describes how to install the ssh2 extension when php accesses sftp in OS X system, including some content, and hope to be helpful to the PHP Tutorial.