{"id":4671,"date":"2018-09-27T00:16:55","date_gmt":"2018-09-27T00:16:55","guid":{"rendered":"https:\/\/geekdecoder.com\/?p=4671"},"modified":"2018-09-27T00:16:55","modified_gmt":"2018-09-27T00:16:55","slug":"how-to-install-ssh2-extension-for-php-on-plesk","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2018\/09\/27\/how-to-install-ssh2-extension-for-php-on-plesk\/","title":{"rendered":"How to install SSH2 extension for PHP on Plesk?"},"content":{"rendered":"<p>Check settings in plesk: Tools and Settings &gt; General &gt; PHP Settings. Click on a php version:<br \/>\n<a href=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpsettings.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-4688\" src=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpsettings-1024x237.png\" alt=\"\" width=\"640\" height=\"148\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpsettings-1024x237.png 1024w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpsettings-300x69.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpsettings-768x177.png 768w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpsettings.png 1281w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<h3>Through the OS vendor (CentOS 7 PHP 5.4.16 OS Vendor)<\/h3>\n<p>Connect to the server via SSH;<\/p>\n<p>Install the pre-compiled extension packages: .rpm-based distribution (CloudLinux, CentOS, RHEL):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># yum install -y epel-release\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># yum install -y php-pecl-ssh2\n<\/pre>\n<p>.deb-based distribution (Debian, Ubuntu):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># apt install -y php-ssh2\n<\/pre>\n<p>Restart apache:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># service httpd restart\n<\/pre>\n<p>Reload the handler<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># plesk bin php_handler --reread\n<\/pre>\n<p>You can check with php -m<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># php -m\nssh2\n<\/pre>\n<p>Check with php info file:<br \/>\n<a href=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpssh2a.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4681\" src=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpssh2a.png\" alt=\"\" width=\"613\" height=\"145\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpssh2a.png 613w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpssh2a-300x71.png 300w\" sizes=\"auto, (max-width: 613px) 100vw, 613px\" \/><\/a><br \/>\n<a href=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpssh2b.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4683\" src=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpssh2b.png\" alt=\"\" width=\"604\" height=\"109\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpssh2b.png 604w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpssh2b-300x54.png 300w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/a><\/p>\n<p>Check command line:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># php -i | grep ssh2\n\/etc\/php.d\/ssh2.ini,\nRegistered PHP Streams =&amp;gt; https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar, ssh2.shell, ssh2.exec, ssh2.tunnel, ssh2.scp, ssh2.sftp, zip\nPHP Warning:  Unknown: It is not safe to rely on the system&#039;s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone &#039;UTC&#039; for now, but please set date.timezone to select your timezone. in Unknown on line 0\nlibSSH Version =&amp;gt; libssh2\/1.4.3\nssh2\nlibssh2 version =&amp;gt; 1.4.3\nbanner =&amp;gt; SSH-2.0-libssh2_1.4.3\n\n<\/pre>\n<p>Check in Plesk. Tools and Settings &gt; General &gt; PHP Settings &gt; Click on 5.4.16 by OS vendor FPM application<br \/>\n<a href=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2018\/09\/php7-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-4701\" src=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2018\/09\/php7-1-1024x355.png\" alt=\"\" width=\"640\" height=\"222\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/php7-1-1024x355.png 1024w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/php7-1-300x104.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/php7-1-768x266.png 768w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/php7-1.png 1181w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><\/p>\n<h3>Plesk PHP 5.6<\/h3>\n<p>Install Development packages:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># yum install plesk-php56-devel gcc libssh2-devel\n<\/pre>\n<p>Install all ssh2:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># \/opt\/plesk\/php\/5.6\/bin\/pecl install ssh2-0.13\n<\/pre>\n<p>Register extension in configuration file:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># echo &quot;extension=ssh2.so&quot; &gt; \/opt\/plesk\/php\/5.6\/etc\/php.d\/ssh2.ini\n\nUpdate PHP handlers information:<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># plesk bin php_handler --reread\nThe information about PHP handlers was successfully updated.\n<\/pre>\n<p>Restart PHP-FPM:<br \/>\nFind the plesk version:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">#  plesk bin php_handler --list | grep -E plesk.*fpm | awk -F&quot; &quot; &#039;{ print $1 }&#039;\nplesk-php56-fpm\nplesk-php70-fpm\nplesk-php71-fpm\nplesk-php72-fpm\n<\/pre>\n<p>Restart the applicable servie for your environment, In this case, plesk-php56-fpm<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># service plesk-php56-fpm restart\n\n<\/pre>\n<p>You can check with a phpinfo file here:<\/p>\n<p><a href=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpssh2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4678\" src=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpssh2.png\" alt=\"\" width=\"936\" height=\"264\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpssh2.png 936w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpssh2-300x85.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/phpssh2-768x217.png 768w\" sizes=\"auto, (max-width: 936px) 100vw, 936px\" \/><\/a><\/p>\n<h4>Plesk PHP 7.0 and Above<\/h4>\n<p>Note: In following instructions &#8216;7.0&#8217; should be replaced with &#8216;7.1&#8217; to install the extension for PHP 7.1.<br \/>\nConnect to the server via SSH<\/p>\n<p>Install all required packages: .rpm-based distribution (CloudLinux, CentOS, RHEL):<\/p>\n<p>Note: Following steps describe the installation of developer packages for PHP 7.0. For PHP 7.2, for instance, plesk-php72-devel or plesk-php72-dev must be installed.<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># yum install -y plesk-php70-devel gcc libssh2-devel\n<\/pre>\n<p>.deb-based distribution (Debian, Ubuntu):<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># apt install -y plesk-php70-dev gcc libssh2-1-dev\n<\/pre>\n<p>Build the extension:<br \/>\nInstall the extension:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># \/opt\/plesk\/php\/7.0\/bin\/pecl install ssh2-1.1.2\ndownloading ssh2-1.1.2.tgz ...\nStarting to download ssh2-1.1.2.tgz (32,057 bytes)\n.........done: 32,057 bytes\n6 source files, building\nrunning: phpize\nConfiguring for:\nPHP Api Version:         20151012\nZend Module Api No:      20151012\nZend Extension Api No:   320151012\nlibssh2 prefix? &#x5B;autodetect] :\n\n<\/pre>\n<p>Hit enter and you should see he the build successful<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">building in \/tmp\/pear-build-rootSbcR3r\/ssh2-1.1.2\nrunning: \/tmp\/ssh2\/configure --with-php-config=\/opt\/plesk\/php\/7.0\/bin\/php-config --with-ssh2\nchecking for grep that handles long lines and -e... \/usr\/bin\/grep\n......\n\nBuild process completed successfully\nInstalling &#039;\/opt\/plesk\/php\/7.0\/lib64\/php\/modules\/ssh2.so&#039;\ninstall ok: channel:\/\/pecl.php.net\/ssh2-1.1.2\nconfiguration option &quot;php_ini&quot; is not set to php.ini location\nYou should add &quot;extension=ssh2.so&quot; to php.ini\n...\n<\/pre>\n<p>Register extension in configuration file:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># echo &quot;extension=ssh2.so&quot; &gt; \/opt\/plesk\/php\/7.0\/etc\/php.d\/ssh2.ini\n\n<\/pre>\n<p>Update PHP handlers information:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># plesk bin php_handler --reread\nThe information about PHP handlers was successfully updated.\n<\/pre>\n<p>Restart PHP-FPM:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"># service plesk-php70-fpm restart\n\n<\/pre>\n<p>Now you can go to Tools and Settings &gt; General &gt; PHP Settings &gt; 7.0.32 FPM application (or any of the activated 7.0.32 links). And you should see:<br \/>\n<a href=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2018\/09\/php7-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-large wp-image-4701\" src=\"https:\/\/qbytes.cloud\/wp-content\/uploads\/2018\/09\/php7-1-1024x355.png\" alt=\"\" width=\"640\" height=\"222\" srcset=\"https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/php7-1-1024x355.png 1024w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/php7-1-300x104.png 300w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/php7-1-768x266.png 768w, https:\/\/www.qbytes.cloud\/wp-content\/uploads\/2018\/09\/php7-1.png 1181w\" sizes=\"auto, (max-width: 640px) 100vw, 640px\" \/><\/a><br \/>\nOther sources:<br \/>\nhttps:\/\/support.plesk.com\/hc\/en-us\/articles\/213930085-How-to-install-SSH2-extension-for-PHP-<br \/>\nhttps:\/\/www.simplecloudhosting.net\/cloud\/index.php?rp=\/knowledgebase\/47\/How-to-Install-the-PHP-SSH2-Extension.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Check settings in plesk: Tools and Settings &gt; General &gt; PHP Settings. Click on a php version: Through the OS vendor (CentOS 7 PHP 5.4.16 OS Vendor) Connect to the server via SSH; Install the pre-compiled extension packages: .rpm-based distribution (CloudLinux, CentOS, RHEL): # yum install -y epel-release # yum install -y php-pecl-ssh2 .deb-based distribution &#8230; <a title=\"How to install SSH2 extension for PHP on Plesk?\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2018\/09\/27\/how-to-install-ssh2-extension-for-php-on-plesk\/\" aria-label=\"Read more about How to install SSH2 extension for PHP on Plesk?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[84,86],"tags":[],"class_list":["post-4671","post","type-post","status-publish","format-standard","hentry","category-php","category-plesk"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/4671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=4671"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/4671\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=4671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=4671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=4671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}