3

I am trying to set permissions with

sudo 775 - R  /var/www/

on all folders and all files in the www folder of lamp for sudo user.

Is this the correct way to set up the system?

belacqua
  • 23,120
Amit Bera
  • 133
  • 2
  • 9

1 Answers1

5

The proper permission under /var/www/ is 755 for folders and 644 for files.

  • The value for 755 is readable by User, Group, and World, writable by User, executable by User, Group, and World. For uploading folder it should be different, and you should change manually.

  • Whereas the value for 644 is readable by User, Group, and World, but writable only by User.

The short command to set folder and file under /var/www/ to 755 and 644 is:

find /var/www -type d -exec chmod 755 {} \; 

find /var/www -type f -exec chmod 644 {} \;

These are simple commands so you will get all folder and files into these permissions, of course, that is not the best practice, it would better if you set spesifically the folders or files that you want to set (I edit this answers after considering comments from AzkerM).

metamorph
  • 1,673
  • Assigning 644 to the whole root in /var/www directory is not a good practice though. Instead OP can try assigning permissions to the necessary directories as needed. – AzkerM May 14 '14 at 07:43
  • It would be better if you describe in a structured, so everyone will know how best we should do :) That includes me will learn from it. – metamorph May 15 '14 at 10:30
  • There is nothing wrong in your answer but it is always better to add a precaution advising the OP about the permissions. After all, the whole www directory will face the public. A simple permission issue can cause lots of problems. Keep up your good work. :) – AzkerM May 15 '14 at 11:07
  • Thank you AzkerM for your suggestion, I have edited my answers, thank you again :) – metamorph May 15 '14 at 11:19