Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rescenic/a051d3a192cf1878e5687250f26486e9 to your computer and use it in GitHub Desktop.
Save rescenic/a051d3a192cf1878e5687250f26486e9 to your computer and use it in GitHub Desktop.
Set SELinux, ACL and common permissions to Drupal 8 over CentOs 7
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
# set -o xtrace
echo "0.- Reestablecer el contexto"
sudo restorecon -Rv /var/www/html
echo "1.- Cambiar propietario del webroot de Apache"
sudo chown -R apache:apache /var/www/html
echo "2.- Cambiar permisos en forma recursiva al webroot de Apache"
sudo chmod -R g+w /var/www/html
echo "3.- Cambiar permisos sólo al webroot de Apache"
sudo chmod g+s /var/www/html
echo "4.- Establecer permisos 755 a todos los directorios"
sudo find /var/www/html -type d -exec chmod 0755 {} \;
echo "5.- Establecer permisos 644 a todos los archivos"
sudo find /var/www/html -type f -exec chmod 0644 {} \;
echo "6.- Establecer permisos 750 a los archivos del sitio principal"
sudo chmod -R 0750 /var/www/html/sites/default/files
echo "7.- Establecer permisos de SELinux"
sudo chcon -Rt httpd_sys_content_t /var/www/html
sudo chcon -Rt httpd_sys_rw_content_t /var/www/html/sites/default/files
sudo chcon -Rt httpd_sys_rw_content_t /var/www/html/modules
sudo chcon -Rt httpd_sys_rw_content_t /var/www/html/vendor
echo "8.- Establecer ACL"
sudo setfacl -R -m u:apache:rwx /var/www/html
sudo setfacl -R -m d:u:apache:rwx /var/www/html
sudo setfacl -R -m g:apache:rwx /var/www/html
sudo setfacl -R -m d:g:apache:rwx /var/www/html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment