Created
June 10, 2017 11:14
-
-
Save bilaschandra/6dd7645c40cc5c9421f33d91e9068be2 to your computer and use it in GitHub Desktop.
SELinux base common permissions set to web application in CentOs 7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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