Install PHP’s SSH2 extension on Ubuntu and Mac


sudo apt-get install libssh2-1-dev libssh2-php
php -m |grep ssh2 #you should see ssh2
sudo service apache2 restart  #apache restart if you are using apache
sudo service php5-fpm restart #fpm restart if you are using php5-fpm

Mac, using mac port

sudo port -v selfupdate
sudo port install php54-ssh2

#add this to the php.ini file /etc/php.ini, it can be placed at the end of the file

sudo /usr/sbin/apachectl restart

Mac, using homebrew

brew install php54-ssh2


What is ssh2?

ssh stands for secure shell, it provides an encrypted channel for logging into another computer and do things on that computer from your computer. ssh2 is an upgrade of ssh, which makes ssh2 more secure and efficient. ssh and ssh2 usually comes with the default command line shell in your operating system, and you can just use them. But if you find yourself doing a routine task everyday such as log into a server, and run a command line on that server and then logout. You are tired of doing this manually everyday and you want to write a program to do it for you. In this case, a php program. Since ssh or ssh2 is not built in within the core php, you will need to install the php ssh2 extension in order write the php program to do this boring daily task for you.

What is apt-get?

apt-get is a default package manager tool in Ubuntu, which you can use it to install new software packages in Ubuntu.

What is mac port?

mac port is a default package manager tool in Mac, which you can use it to install new software packages in Mac.

What is homebrew?

homebrew is a very popular open source package manager tool for Mac, you can download it from Some people find it easier and better than the default package manager.

Search within Codexpedia

Custom Search

Search the entire web

Custom Search