For Development
1 2 3 4 |
chown www-data:www-data -R * # Let Apache be owner find . -type d -exec chmod 755 {} \; # Change directory permissions rwxr-xr-x find . -type f -exec chmod 644 {} \; # Change file permissions rw-r--r-- sudo chown -R www-data:www-data www/html/folder/ |
In production, I wouldn’t give access to users to modify the filesystem, I’ll only allow them to upload resources and give access to some plugins specific folders to do backups, etc. But managing projects under Git and using deploy keys on the server, it isn’t good update plugins on staging nor production. I leave here the production file setup:
1 2 |
# Set uploads folder user and group to www-data chown www-data:www-data -R wp-content/uploads/ |
www-data:www-data = apache or nginx user and group
Staging will share the same production permissions as it should be a clone of it.
Finally, development environment will have access to update plugins, translations, everything…
1 2 3 4 5 6 7 8 |
# Set uploads folder user and group to www-data chown www-data:www-data -R wp-content/ # Set uploads folder user and group to www-data chown your-user:root-group -R wp-content/themes # Set uploads folder user and group to www-data chown your-user:root-group -R wp-content/plugins/your-plugin |
www-data:www-data = apache or nginx user and group your-user:root-group = your current user and the root group
These permissions will give you access to develop under themes
and your-plugin
folder without asking permission. The rest of the content will be owned by the Apache or Nginx user to allow WP to manage the filesystem.
Before creating a git repo first run these commands:
1 2 3 4 5 |
# Set all directories permissions to 755 find . -type d -exec chmod 755 {} \; # Set all files permissions to 644 find . -type f -exec chmod 644 {} \; |