DazREIT wrote:
I’ve tried this:
chmod -R ugo+xwr /home/DazREIT/www/*
Egads, don’t do this.
In the order you see them with ls -l, it’s User Group Other, having Read, Write, and eXecute permissions. 777 means “anyone, even if they are not the owner or even in the appropriate group, can modify or destroy these files.”
The numeric values are:
4 = read
2 = write
1 = execute
So 7 gives all permissions. 5 gives read and execute. 6 gives read and write. These are the most common combos.
Note that using the numbers absolutely sets permissions, no matter what they were before, while using the letters gives or takes them and will not affect anything that already has 'em.
Frex,
chmod -R o-w /path/to/dir
which will “remove write permissions from Others recursively” through the target directory, without killing website visitors’ ability to Read and Execute those files (directories must be Executable to the user in order to be traversed).
You can handle yours and Apache’s permissions using group membership.
For example… assuming you have an account with a strong password, why not secure the files via
chown -R www-data:www-data /home/user/www (giving Apache ownership and letting it run)
chmod -R 775 /home/user/www
This gives the www-data user full control, anyone in the www-data group full control, and read / execute permissions to everyone else, i.e. your website visitors.
All you have to do now is add your own user account to the www-data group.