3

I am in need of using PHP from the command line. When I type

php ....

The system says:

-bash: php: command not found

Now, I know for fact that PHP is up and running b/c it hosts my drupal site. I'm not sure how to find the program. I'm searching through the directories for the path without any success.

What am I missing?

I am using Ubuntu Linux.

I have the following packages installed:

php5                                            install
php5-common                                     install
php5-curl                                       install
php5-gd                                         install
php5-mcrypt                                     install
php5-mysql                                      install
2
  • What is the output from whereis php?
    – Nobody
    Aug 22, 2011 at 15:08
  • Which server OS are you using? Which package-manager are you using?
    – hakre
    Aug 22, 2011 at 15:11

4 Answers 4

9

Probably you need to install the CLI (command line interpreter) package. In Ubuntu or Debian this can be done via apt-get install php5-cli

7
  • 1
    How do you know he uses a system that has apt?
    – Nobody
    Aug 22, 2011 at 15:07
  • 2
    It's pretty much the norm these days, and if the assumption is wrong then an edit can be made once the OP responds.
    – ridecar2
    Aug 22, 2011 at 15:09
  • How do you know the package is called php5-cli and not php-cli for example?
    – hakre
    Aug 22, 2011 at 15:10
  • 2
    Don't speculate, let the OP respond. But as an indicator he tagged this question with php5
    – akirk
    Aug 22, 2011 at 15:11
  • There's the correct answer then.
    – ridecar2
    Aug 22, 2011 at 15:21
2

Most distributions split mod_php (the Apache module) and the PHP command line executable into separate packages. You will need to find the CLI package and install it.

0

If you believe that php is already on the system you can try

locate php

to find the program.

0

As akirk has hinted, the PHP which runs stuff on your webserver is probably not the same bit of code of which runs stuff from the command line.

Without knowing what distribution of Linux this is / what non-standard configurations have been applied we can't advise how to install the appropriate version of PHP / determine the location of an existing installation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .