Install libssh2 using MacPorts:
$ sudo port install libssh2
Install ssh2 to PHP:
$ sudo pecl install channel://pecl.php.net/ssh2-0.11.2
When asked for libssh2 prefix, enter /opt/local and press Enter.
Pecl will now install ssh2.
Add the following line to /etc/php.ini:
extension=ssh2.so
Restart Apache:
$ sudo apachectl restart
And you’re done! PHP can now use SSH2.