Survey

Selasa, 24 Juni 2014

CentOS 6.4 - Install SSH2 extension for PHP

CentOS 6.4 - Install SSH2 extension for PHP















Hari ini test send file via sftp dengan  php. Berikut ini adalah snippet code untuk test send file:
public function index(){
$connection = ssh2_connect('localhost', 22); if ($connection) {
ssh2_auth_password($connection, 'user', password');
// send a file
ssh2_scp_send($connection,  '/local/filename','/remote/filename', 0644);
} else {
print_r('not connect');
}
}

Tapi ketika run file php nya terjadi terjadi error
PHP Fatal error: Call to undefined function ssh2_connect()

Setelah gooling.... Akhirnya dapat mantra untuk install ssh2 terlebih dahulu. Dengan langkah-langkah sebagai berikut:

1. Install the necessary packages before you can build/install ssh2 extension
yum install gcc php-devel php-pear libssh2 libssh2-devel make

2. Install the extension, (hit enter for autodetect when it prompts you)
pecl install -f ssh2

3. Once the install is completed, you just have to tell PHP to load the extension when it boots.
echo extension=ssh2.so > /etc/php.d/ssh2.ini

4. Restart your webserver and test to see if the changes took effect.
service httpd restart

5. You can check it installed with the following command
php -m | grep ssh2

Jakarta, 24 Juni 2014
by waw

1 komentar:

kalau untuk melakukan perintah pada vps snippet codenya kayak gimana ya?

Posting Komentar

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More