Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 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

share|improve this question
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
up vote 8 down vote accepted

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

share|improve this answer

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.

share|improve this answer

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).

share|improve this answer

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

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.