Reputation: 2028
I have a LAMP server where I've run the following commands to set permissions of files in /var/www:
groupadd web
usermod -a -G web my_user
chown -R root:web /var/www
chmod -R 775 /var/www
chmod -R g+s /var/www
My goal is to have all files writable by any member of the "web" group. Is there a secure way to allow file uploads (e.g. within Wordpress) without changing the file ownership? Note: this is a private server.
Upvotes: 0
Views: 1922
Reputation: 312038
One way of applying permissions to just directories is to use the find
command. For example:
# Set the owner and group on everything.
chown -R root:web /var/www
# Make *directories* read/write/execute and set the `sgid` bit.
find /var/www -type d -print | xargs chmod g+rwxs
You don't want to run chmod -R 775 /var/www
because this will make all your files executable, which is probably not what you want.
Upvotes: 1