Skip to content

Instantly share code, notes, and snippets.

@clemlesne
Last active March 19, 2019 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clemlesne/22e76e25d4ee0854297a84b8bc64c803 to your computer and use it in GitHub Desktop.
Save clemlesne/22e76e25d4ee0854297a84b8bc64c803 to your computer and use it in GitHub Desktop.
Proper permissions for web server's directory

First, fix the owners :

sudo chgrp -R www-data .

Then, fix the access permissions :

For read-only folders :

sudo find . -type f -exec chmod 0460 {} \;
sudo find . -type d -exec chmod 2570 {} \;

For "storage" folders :

sudo find . -type f -exec chmod 0660 {} \;
sudo find . -type d -exec chmod 2770 {} \;

Nginx need to have +x access on all directories leading to the site's root directory:

chmod +x /home/
chmod +x /home/username
chmod +x /home/username/siteroot

Wordpress website :

sudo find . -type f -exec chmod 664 {} +
sudo find . -type d -exec chmod 775 {} +
sudo chmod 660 wp-config.php

Enable the access to nginx from SElinux:

chcon -Rt httpd_sys_content_t /path/to/www
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment