Avatar of Nathan Riley
Nathan Riley
Flag for United States of America asked on

PHP Command Not Working in SSH

I'm trying to figure out why the php command is not working in SSH for me.  PHP 7 is installed on centos 7 server.

bash: php: command not found

But I know php is installed as I have php sites running on the box. Not sure where it's installed or what the problem is.
PHPLinux

Avatar of undefined
Last Comment
Kent W

8/22/2022 - Mon
Kent W

Do a
yum list installed php*

See if "php-cli" is installed.

If not, then
yum install php-cli
gr8gonzo

It's probably just not in your path.

Try these two steps:
updatedb (only needs to be run once to update the locate index)
locate php | grep -P "/php$"

The locate command should show you all files on the server with "php" in their filename or folder name. The "grep" pipe filters down the results down to just things that end in "/php".

That should give you a pretty short list.

From there, you can always do a soft-link to a common bin folder so you can run it from anywhere:
ln -s <full path of the PHP binary> /usr/bin/php

After you do that, you should be able to call php from anywhere.
Nathan Riley

ASKER
@mugojava - I got an error it conflicts with php 7 when trying to install cli.

@gr8gonzo - I tried updatedb and locate command both of which said command not found.  I'm on centos 7 not sure if syntax is different.

Thanks
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Julian Hansen

Put this in a file
pi.php
<?php
phpinfo();

Open in new window

Save that in your Web root and browse to it
Look in the results for the Path to PHP

Test on the command line by prefixing the call to php with the path - if that works add the path to your system path.
Nathan Riley

ASKER
@Julian - I have it here, but not seeing it: http://forums.starcitizenbase.com/phpinfo.php
Kent W

Search yum did your particular php install.
It may be called php*-cli

Replace * with the version tag you have installed.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
gr8gonzo

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Kent W

You can also do a
Yum list installed php*
If you have php70 installed, for instance, you can install cli correct version with
yum install php70-cli

Substitute php56-cli if you have php 5.6 installed, etc.
Nathan Riley

ASKER
@mugojava -

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.cc.columbia.edu
 * epel: mirror.symnds.com
 * extras: reflector.westga.edu
 * ius: mirror.symnds.com
 * remi-safe: mirrors.mediatemple.net
 * updates: ftp.osuosl.org
Installed Packages
php70u-common.x86_64                                                                                                7.0.9-2.ius.centos7                                                                                               @ius
php70u-gd.x86_64                                                                                                    7.0.9-2.ius.centos7                                                                                               @ius
php70u-json.x86_64                                                                                                  7.0.9-2.ius.centos7                                                                                               @ius
php70u-mbstring.x86_64                                                                                              7.0.9-2.ius.centos7                                                                                               @ius
php70u-mcrypt.x86_64                                                                                                7.0.9-2.ius.centos7                                                                                               @ius
php70u-mysqlnd.x86_64                                                                                               7.0.9-2.ius.centos7                                                                                               @ius
php70u-opcache.x86_64                                                                                               7.0.9-2.ius.centos7                                                                                               @ius
php70u-pdo.x86_64                                                                                                   7.0.9-2.ius.centos7                                                                                               @ius
php70u-xml.x86_64                                                                                                   7.0.9-2.ius.centos7                                                                                               @ius
[root@ip-172-31-13-72 httpd]# yum install php70-cli
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.cc.columbia.edu
 * epel: mirror.symnds.com
 * extras: reflector.westga.edu
 * ius: mirror.symnds.com
 * remi-safe: mirrors.mediatemple.net
 * updates: ftp.osuosl.org
No package php70-cli available.
Error: Nothing to do

Open in new window

Nathan Riley

ASKER
gr8gonzo -

[root@ip-172-31-13-72 httpd]# updatedb
[root@ip-172-31-13-72 httpd]# locate php | grep -P "/php$"
/usr/lib64/php
/usr/share/php
/var/lib/php

Open in new window

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER CERTIFIED SOLUTION
Kent W

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.