{"id":693,"date":"2020-10-01T14:14:11","date_gmt":"2020-10-01T08:14:11","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=693"},"modified":"2020-10-01T14:14:11","modified_gmt":"2020-10-01T08:14:11","slug":"how-to-add-php-in-default-path-for-plesk-how-to-fix-bash-php-command-not-found-for-plesk-user","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/how-to-add-php-in-default-path-for-plesk-how-to-fix-bash-php-command-not-found-for-plesk-user.html","title":{"rendered":"How to Add PHP in Default Path for Plesk \/ How to Fix -bash: php: command not found for Plesk User"},"content":{"rendered":"\n<p>If you have added SSH access to your plesk user using the following tutorial:<\/p>\n\n\n\n<figure class=\"wp-block-embed-wordpress wp-block-embed is-type-wp-embed is-provider-mellowhost-blog\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"GhBMWwd0II\"><a href=\"https:\/\/mellowhost.com\/blog\/how-to-enable-ssh-in-plesk-user-domain.html\">How to Enable SSH in Plesk User Domain<\/a><\/blockquote><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;How to Enable SSH in Plesk User Domain&#8221; &#8212; Mellowhost Blog\" src=\"https:\/\/mellowhost.com\/blog\/how-to-enable-ssh-in-plesk-user-domain.html\/embed#?secret=GhBMWwd0II\" data-secret=\"GhBMWwd0II\" width=\"600\" height=\"338\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>and then, tried to run php command like the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[elastic-keldysh@pl1 ~]$ php -v\n-bash: php: command not found\n<\/pre>\n\n\n\n<p>You might have encountered the above error. This is because plesk do not store the php binary in your PATH variable locations. You may check your existing path variables here:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[elastic-keldysh@pl1 ~]$ echo $PATH\n\/usr\/share\/Modules\/bin:\/usr\/local\/bin:\/usr\/bin:\/usr\/local\/sbin:\/usr\/sbin<\/pre>\n\n\n\n<p>Plesk stores it&#8217;s php binaries for different versions here:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/opt\/plesk\/php\/<\/pre>\n\n\n\n<p>So, for example if you are trying to use PHP 7.4 binary, this would be like the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[elastic-keldysh@pl1 php]$ \/opt\/plesk\/php\/7.4\/bin\/php -v\nPHP 7.4.10 (cli) (built: Sep  4 2020 03:49:35) ( NTS )\nCopyright (c) The PHP Group\nZend Engine v3.4.0, Copyright (c) Zend Technologies\n    with the ionCube PHP Loader + ionCube24 v10.4.2, Copyright (c) 2002-2020, by ionCube Ltd.\n    with Zend OPcache v7.4.10, Copyright (c), by Zend Technologies\n<\/pre>\n\n\n\n<p>So, to use only php -v, you need to add this bin path to your path variable. You may do that by running the following command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">PATH=$PATH:\/opt\/plesk\/php\/7.4\/bin\/<\/pre>\n\n\n\n<p>Now, you may run the following and it will work:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[elastic-keldysh@pl1 php]$ php -v\nPHP 7.4.10 (cli) (built: Sep  4 2020 03:49:35) ( NTS )\nCopyright (c) The PHP Group\nZend Engine v3.4.0, Copyright (c) Zend Technologies\n    with the ionCube PHP Loader + ionCube24 v10.4.2, Copyright (c) 2002-2020, by ionCube Ltd.\n    with Zend OPcache v7.4.10, Copyright (c), by Zend Technologies\n<\/pre>\n\n\n\n<p>Now, we need to remember, this will only sustain for the existing session, if we log out and re login, this would be lost. To keep this permanent on each login, we need to put this in the .profile file. You may do this by running the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">echo \"PATH=$PATH:\/opt\/plesk\/php\/7.4\/bin\/\" >> .profile<\/pre>\n\n\n\n<p>Once done, now you may try to login back again and see php -v is still working:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[elastic-keldysh@pl1 ~]$ exit\nlogout\n[root@pl1 ~]# su - elastic-keldysh\nLast login: Thu Oct  1 13:42:13 IST 2020 on pts\/0\n[elastic-keldysh@pl1 ~]$ php -v\nPHP 7.4.10 (cli) (built: Sep  4 2020 03:49:35) ( NTS )\nCopyright (c) The PHP Group\nZend Engine v3.4.0, Copyright (c) Zend Technologies\n    with the ionCube PHP Loader + ionCube24 v10.4.2, Copyright (c) 2002-2020, by ionCube Ltd.\n    with Zend OPcache v7.4.10, Copyright (c), by Zend Technologies\n[elastic-keldysh@pl1 ~]$\n<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have added SSH access to your plesk user using the following tutorial: and then, tried to run php command like the following: You might have encountered the above error. This is because plesk do not store the php binary in your PATH variable locations. You may check your existing path variables here: Plesk &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/how-to-add-php-in-default-path-for-plesk-how-to-fix-bash-php-command-not-found-for-plesk-user.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Add PHP in Default Path for Plesk \/ How to Fix -bash: php: command not found for Plesk User&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[144,273,509,150],"tags":[512,275,510],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/693"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=693"}],"version-history":[{"count":1,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/693\/revisions"}],"predecessor-version":[{"id":694,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/693\/revisions\/694"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=693"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=693"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=693"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}