Imposta Permessi 644
IMPOSTAZIONE PERMESSI 644
Con il seguente script รจ possibile impostare i giusti permessi per un sito Wordpress:
Bash
#!/bin/bash
if [ "$EUID" -ne 0 ]; then
echo "Per favore, esegui questo script come root"
exit
fi
echo "Inserisci il nome del dominio per cui vuoi settare i permessi (esempio.com oppure sub.esempio.com):"
read -p "Dominio: " domain
# domain=letsengim/wordpress
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=/var/www/$domain/wordpress # <-- wordpress root directory
WS_GROUP=www-data # <-- webserver group
# reset to safe defaults
find ${WP_ROOT} -exec chown ${WP_OWNER}:${WP_GROUP} {} \;
find ${WP_ROOT} -type d -exec chmod 755 {} \;
find ${WP_ROOT} -type f -exec chmod 644 {} \;
# allow wordpress to manage wp-config.php (but prevent world access)
chgrp ${WS_GROUP} ${WP_ROOT}/wp-config.php
chmod 640 ${WP_ROOT}/wp-config.php # Impostato a 640 per limitare i permessi
# allow wordpress to manage .htaccess
touch ${WP_ROOT}/.htaccess
chgrp ${WS_GROUP} ${WP_ROOT}/.htaccess
chmod 644 ${WP_ROOT}/.htaccess # Impostato a 644 per limitare i permessi
# allow wordpress to manage wp-content
find ${WP_ROOT}/wp-content -exec chown -R ${WP_OWNER}:${WS_GROUP} {} \; # Modificato il gruppo a WS_GROUP per wp-content
find ${WP_ROOT}/wp-content -type d -exec chmod 775 {} \;
find ${WP_ROOT}/wp-content -type f -exec chmod 664 {} \;
### ESITO ###
echo "I permessi sono stati impostati correttamente"