I have a php file test.php


  echo "test";

This file owned by root and its permissions are these


so 'others' can execute, but cannot read.

When logged in as other user than root and trying to run this file from the command line

php test.php 

Got the following error

Could not open input file: test.php

If given +r permission it works.

I thought that only execute permission was needed.

Does a PHP file need read permission to 'others' to be executed in command line?

Note: using Ubuntu 10.04 LTS and PHP 5.3.2

  • You execute the file called php, not the test.php. The test.php is read and interpreted by file (program) named php (which is actually a symlink). – takeshin Sep 2 '10 at 17:55

Having only execute permission is fine if it is a binary. Scripts must have read permission so that their interpreter can read them.


if you execute the script directly either using the full path or ./test.php with a shebang line it will need to be executable. If you specify the interpreter (ie. php) it's the interpreter that needs to be able to execute code, so in this case it only needs to be able to read the code.


Yes, the file needs to be readable for the user you try to run it with. On a side note, the executable bit doesn't need to be set if you call it the way you do (php /path/to/script.php).


Yes, scripts (non-binary files) need r+x permission to execute.

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.