0

How can I set chmod 777 for my lamp server?

I am the owner of the www folder (sudo chown -R martin www). I have changed the permissions of all files (sudo chmod 777 -R www).

I don't know why, but my website is working only with chmod 777. Otherwise I see only white page.

I'm working with .tpl files (include file="header.tpl", but when I use a new file , it will be not shown until I make chmod 777 for that file).

How can I set chmod 777 permanently for all new files in this folder?

guntbert
  • 13,134
Martin Munka
  • 37
  • 1
  • 4

1 Answers1

3

Actually you should never ever make web root writable. See Why should /var/www not have chmod 777?

I suspect what you really want to do is to set the directories to 755 and, either leave the files alone, or set them to 644. For this you can use the find command e.g.

To change all the directories to 755:

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

To change all the files to 644:

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

Also, to give permissions for files to be seen in browser, use:

chown -R www-data:www-data /var/www/

If your www directory is not in /var, change /var/www with the right way.

Update: Any new files copied to the folder /var/www would not have your custom set permissions. You would need to run the command again to set the permissions for new files too.

Radu Rădeanu
  • 169,590
  • and when I create a new file somewhere in /var/www/ it will be automaticaly 755? – Martin Munka May 14 '13 at 19:13
  • 1
    Source: http://stackoverflow.com/questions/3740152/how-to-set-chmod-for-a-folder-and-all-of-its-subfolders-and-files-in-linux-ubunt – duxk.gh May 17 '13 at 12:12