I want to tell you why chmoding to 777 is not necessary.
See the other answers on how to set the permissions.
I'd strongly discourage chmoding to 777.
At most chmod to 775, that should give you more than enough rights and leave you a little less exposed.
Just in case you're not familiar what 777 or 775 means I'll explain it here:
- The first digit sets the permissions for the owner (user) of the
- The second digit sets the permissions for all the users in the
group that owns the file.
- The third digit will set permissions to all
the other users.
The value of each digit can range from 0 to 7.
It defines if a user can read, write or execute the file.
The above mentioned permissions each have a value:
You can add up the values of the required permissions to get one digit.
For example: lets say the owner of the File should be allowed all, the group only read and write and the rest should only be allowed to read a file:
- User: 1+2+4=7
- Group: 2+4=6
- World: 4=4
This would result in the following command:
chmod 764 /somedir
For a webserver 755 should normally be more than sufficient.
I'm assuming that the owner of the files is the same, as the one the webserver is running under, thus you and you're scripts will have write permission.
In environments with multiple websites often the user is set per site and the group is used for all websites. So if the group has write permissions a badly configured server can lead to others being able to change your files.
For all the other users (world) it is absolutely not necessary to be able to modify your files. You could probably even set the permissions for world to 0 (no permissions) and it would not break your site.
This depends on your setup though.