LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Invoking a PHP script - sometimes the full path is required (https://www.linuxquestions.org/questions/linux-newbie-8/invoking-a-php-script-sometimes-the-full-path-is-required-644522/)

sneakyimp 05-24-2008 02:39 PM

Invoking a PHP script - sometimes the full path is required
 
I have noticed that sometimes I can invoke a php script like this:
Code:

linux_prompt# php -q my_script.php
but other times I must type in the full path to the php executable like this:
Code:

linux_prompt# /usr/bin/php5 my_script.php
Why is that? I'm guessing there's an alias somewhere. Is it in my bash profile? Is it possible to create one alias that applies to *all* users of a linux box? Also, is it safe to use the path /usr/bin/php every time or will that path vary by linux distribution or php install?

Any help would be very much appreciated.

Tinkster 05-25-2008 01:13 AM

Are you seeing that different behaviour as the same user,
or are you su'ed to someone else?


Cheers,
Tink

sneakyimp 05-25-2008 02:13 PM

I'm not talking about different behavior on a single machine. I'm talking about different behavior from server to server.

chrism01 05-25-2008 06:12 PM

For server to server differences, it means its not always being set in the PATH var.
Fundamentally, you've got
/etc/profile
which is applied to all user logins, and
.bash_profile
which is a hidden file in the home dir of each user and can contain different info eg PATH definitions, for each user.
HTH

seraphim172 05-26-2008 05:38 PM

PATH issue
 
If the location of an application is not in your PATH, then you will have to type the full path name - this is true for every application, not only for PHP.

To run PHP from the command-line it has to have been built with the CLI option. This can be different among different servers.

Linux Archive


All times are GMT -5. The time now is 02:45 PM.