How to USE php CLI

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
pallavan
Forum Newbie
Posts: 1
Joined: Fri Apr 17, 2009 9:28 am

How to USE php CLI

Post by pallavan »

hi friends,
I wanna use the php CLI on my local server.
when I use
-bash:$ php filename.php

it returns like
-bash: php: command not found

but when i give like
/opt/lampp/bin/php filename.php

then it is being executed perfectly!

how can I configure it so that I can run using the former command
ie
php filename
For you information:
my local servers OS :-> federo
and lampp installed.

Thanks
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: How to USE php CLI

Post by pickle »

The command 'php' needs to be in your 'search path' (or something similarly named). When you log in to a Linux box, the shell reads some ini files to determine what your search paths are. When you type in a command, Linux looks through all your search paths to find an equivalent executable file. If it finds one, it runs it. If not, it gives you the error you see.

I'm not exactly sure how to put 'php' in your search path, but now that you know what's happening, Google should be able to help.

Also, I'm moving this to the 'Linux' forum.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply