Dec 15

Execute PHP script from command line

After successful installation of PHP on the web servers, many people confuse how to execute PHP script from command line.
If you follow auto installation procedure such as yum or apt, then PHP CLI feature should be installed by default. If PHP installation done from
compiling source, then there is little steps to follow to get PHP CLI to work .

1) Find PHP bin file

First you should try to find PHP bin and make sure it exist

If PHP binary does exist, you will find path to binary file

If PHP binary does not exist, you may need to recompile PHP

2) Add PHP to bash profile

If PHP exists on your system, add the path to bash_profile

then replace the actual path of the PHP bin

3) save and reload the file

This is to ensure your current session has access to new path changes. otherwise you need to open fresh terminal windows.

4) Verify

now you should be able to run PHP script from cli

Leave Your Thought Here