Skip to content

Instantly share code, notes, and snippets.

@rahilwazir
Last active April 4, 2016 14:01
Show Gist options
  • Save rahilwazir/2b7d7a8c61e675a3e34c to your computer and use it in GitHub Desktop.
Save rahilwazir/2b7d7a8c61e675a3e34c to your computer and use it in GitHub Desktop.
Apply permission for php projects

Do this once

sudo chown www-data:www-data -R <projectpath>
sudo find <projectpath> -type d -exec chmod 755 {} \;
sudo find <projectpath> -type f -exec chmod 644 {} \;
sudo adduser <username> www-data
sudo chmod -R g+rwX <projectpath>
sudo chgrp -R www-data <projectpath>

Do this for existing projects

sudo chown www-data:www-data -R <projectpath>
sudo find <projectpath> -type d -exec chmod 755 {} \;
sudo find <projectpath> -type f -exec chmod 644 {} \;
sudo chmod -R g+rwX <projectpath>

Even great for future files/folders

sudo find . \( -type f -exec setfacl -m g:www-data:rw '{}' ';' \) -o \( -type d -exec setfacl -m g:www-data:rwx '{}' ';' \)

If the setfacl not found, you need to install it:

sudo apt install acl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment