Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have installed a new application, and I wish to run it by a php script(system and exec function), so that others can run it through their browsers. I tried to run that php script in my terminal at location as "php shell.php", and it works, however, when I visit this php page, it says Command not found. It also works in terminal when I logged in a new account(created after the new application installed) and the guest account.

I think that may be caused by PATH settings, but why new account can run it right(it may prove that PATH is global)?

share|improve this question

PATH is only set to a minimal value for the entire system, and it may not include wherever your application is. You'd need to set the PATH for the web server to affect how your app is run by web scripts.

You should probably have your PHP script simply add the directory needed to the PATH right before calling 'system' or 'exec'. That will keep the change contained to this one script.

Another option which may be preferrable is to just call the application by its full path name, so that you don't have to search the path for it. So if it is in /usr/local/bin, just do /usr/local/bin/myapp.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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