I was trying to install PHPUnit following the step-by-step guide in the Getting Started page.

However, when I try phpunit --version in terminal, I receive /usr/local/bin/phpunit: Permission denied.

Trying sudo phpunit --version the error is sudo: phpunit: command not found.

I already tried execute:

$ cd /usr/local/bin
$ ./phpunit --version

The error is bash: ./phpunit: Permission denied and with sudo I get command not found again.

Finally, using php before the command like php phpunit --version I get the expected result, that is PHPUnit 5.0.8 by Sebastian Bergmann and contributors.

I'm considering it a strange behaviour because I already installed PHPUnit in other machines and all worked fine.

So, someone knows why PHPUnit just works with a php before?

Some important information:

Ubuntu 14.04 LTS

PHP 5.6.14

PHPUnit 5.0.8

echo $PATH returns /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin that includes /usr/local/bin

ls -l in /usr/local/bin directory gives me -rw-rw-r-- 1 root root 2766207 Out 23 04:50 phpunit

  • 1
    Right: "-rw-rw-r-- " phpunit has no "x" bit set. Therefore not executable. – ilkhd Nov 5 '15 at 12:14
  • Shame on me! Much more simple than I thought! A simple chmod +x solves the problem. Thx @ilkhd. – James Nov 5 '15 at 14:11

As pointed by @ilkhd in the comments, the problem is inded with permission of the file.

Then, the solution is just:

$ cd /usr/local/bin
$ sudo chmod +x phpunit

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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