Solved

PHP Command Not Working in SSH

Posted on 2016-08-26
11
80 Views
Last Modified: 2016-08-26
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.
0
Comment
Question by:N R
  • 4
  • 4
  • 2
  • +1
11 Comments
 
LVL 12

Expert Comment

by:Kent W
ID: 41772112
Do a
yum list installed php*

See if "php-cli" is installed.

If not, then
yum install php-cli
0
 
LVL 34

Expert Comment

by:gr8gonzo
ID: 41772117
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.
0
 
LVL 11

Author Comment

by:N R
ID: 41772161
@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
0
 
LVL 51

Expert Comment

by:Julian Hansen
ID: 41772265
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.
0
 
LVL 11

Author Comment

by:N R
ID: 41772270
@Julian - I have it here, but not seeing it: http://forums.starcitizenbase.com/phpinfo.php
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 12

Expert Comment

by:Kent W
ID: 41772297
Search yum did your particular php install.
It may be called php*-cli

Replace * with the version tag you have installed.
0
 
LVL 34

Assisted Solution

by:gr8gonzo
gr8gonzo earned 250 total points
ID: 41772302
That's interesting. Usually mlocate (the package that contains the updatedb and locate commands) is on most CentOS installs. No worries - just install it with yum:

yum install mlocate

Then run the same two commands. (By the way, updatedb will take a minute or so to run)
0
 
LVL 12

Expert Comment

by:Kent W
ID: 41772309
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.
0
 
LVL 11

Author Comment

by:N R
ID: 41772316
@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

0
 
LVL 11

Author Comment

by:N R
ID: 41772318
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

0
 
LVL 12

Accepted Solution

by:
Kent W earned 250 total points
ID: 41772325
yum install php70u-cli
Should do the trick.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now