1

I'm trying to run an executable via the cli, like so:

phpunit DefaultTest

but i get "command not found" so i have to do:

/usr/lib/php/bin/phpunit DefaultTest

which works, how do i set it so i only have to use the executable name?

1

You'll have to append /usr/lib/php/bin to your $PATH environment variable. The best way to do this is to edit .bashrc or .profile and add /usr/lib/php/bin at the end of the $PATH like in the example below.

Example:

.profile:

...
...
PATH="/usr/lib/php/bin:$PATH"
4
  • Your example adds it at the beginning. – Ignacio Vazquez-Abrams Sep 2 '10 at 4:27
  • great thanks, that worked. which is better .bashrc or .profile? – mononym Sep 2 '10 at 4:32
  • Ignacio: You're correct. You can do this instead, then: PATH="$PATH:/usr/lib/php/bin" :) – Christian Paredes Sep 2 '10 at 4:38
  • mononym: .profile will work just fine, though if you have a .bash_profile as well, then if you're using bash, bash will favor .bash_profile over .profile AFAIK. – Christian Paredes Sep 2 '10 at 4:39
0

You can also symlink to a place in the standard path. If you need to execute it outside of shell or if it had to be available for all users

sudo ln -s /usr/lib/php/bin/phpunit /usr/local/bin

/usr/local/bin is in the path and is the common location of user installed binaries, so its contents are available for execution systemwide.

2
  • Not really an option, symlinking creates a mess. Basically the only viable solution is altering $PATH – cpf Sep 2 '10 at 16:26
  • I didn't agree. symlinking beyond /usr/local is completly natural way to install system-wide and IMHO is safer than add directories to the global path. As I said for system wide setups. – theist Sep 3 '10 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.