From /var/www, I executed "chmod -R 774 ." and now none of my .php scripts are accessible. From my browser, when I type in mydomain.com or mydomain.com/test2.php or mydomain.com/test.php, I get the 403 Forbidden error msg.

So, I changed the permissions of 3 of the .php scripts to 775, but this didn't help either.

Here is the output from "ls -la /var/www":

drwxrwxr-- 6 john wheel 4096 2010-09-29 17:38 .

drwxr-xr-x 14 root root 4096 2010-09-27 21:15 ..

-rwxrwxr-x 1 john wheel 3353 2010-09-29 05:29 index.php

-rwxrwxr-x 1 john wheel 124 2010-09-27 23:12 .htaccess

-rwxrwxr-x 1 john john 34 2010-09-29 17:39 test2.php

-rwxrwxr-x 1 john john 26 2010-09-28 22:08 test.php

The .htaccess file does a URL mod_rewrite so typing in index.php is not needed.

Thanks for your help.


You need 755 in the directory (note the lacking 'x' for 'others')

The webserver accesses the dir in the context of "others" (it isn't in the group nor is it "john" nor is it "root"). Therefore it needs "x" for "others" in the dir to have access to the contents of the dir. Then it needs the "x" for "others" for every script which gets "executed", e.g. directly accessed via an URL.

  • Thanks! Should I have 755 setting for all my scripts, too? Is this safe? – JMan Sep 29 '10 at 18:15
  • It isn't a problem, but I wouldn't recommend it. Instead chmod the directories only: find /var/www -type d| xargs chmod 755 – mfarver Sep 29 '10 at 18:34

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.