Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nim4n136/5d0784b76b5bd61c70bdb12159bbd3f8 to your computer and use it in GitHub Desktop.
Save nim4n136/5d0784b76b5bd61c70bdb12159bbd3f8 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
# SEliux articel
https://blog.lysender.com/2015/07/centos-7-selinux-php-apache-cannot-writeaccess-file-no-matter-what/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment