Setting files permission in Linux / Ubuntu is sometimes a problem. It can be simplified by running single command like this :
ONLY FOR FILES
find /path/to/site/ -type f -exec chmod 664 {} \
for folders use this one :
find /path/to/site/ -type d -exec chmod 775 {} \;
Posted inUbuntu