[CentOS] Apache and web content permissions

Mon Dec 4 12:58:31 UTC 2017
Nicolas Kovacs <info at microlinux.fr>

Le 02/12/2017 à 16:25, Brian Mathis a écrit :
> You could write a script to open the permissions, apply updates using
> something like http://wp-cli.org/, then close the permissions again.  Run
> it through cron so you get updates in a timely manner.

Here's a little script I wrote to automatically update Wordpress core,
extensions and themes. Works perfectly. I'll run it manually for a few
days, then I guess I'll define a cronjob for it.

# wordpress-update.sh
# Mise à jour automatique de toutes les installations Wordpress
# (c) Nicolas Kovacs <info at microlinux.fr>

# WP-CLI doit être installé

# Apache

# Utilisateur normal

# Racine du serveur Web

# Identifier les installations Wordpress
WPDIRS=$(dirname $(cd $WPROOT && find . -type f -name 'wp-config.php'))

for WPDIR in $WPDIRS; do
  cd $WPROOT
  # Définir les permissions correctes
  find $WPDIR -type d -exec chmod 0755 {} \;
  find $WPDIR -type f -exec chmod 0664 {} \;
  chown -R $WPUSER:$HTGROUP $WPDIR/wp-content
  find $WPDIR/wp-content -type d -exec chmod 0775 {} \;
  find $WPDIR/wp-content -type f -exec chmod 0664 {} \;
  cd $WPDIR
  # Mettre à jour le moteur Wordpress
  su -c "$WP core update" $WPUSER
  # Mettre à jour les extensions
  su -c "$WP plugin update --all" $WPUSER
  # Mettre à jour les thèmes
  su -c "$WP theme update --all" $WPUSER

exit 0



Microlinux - Solutions informatiques durables
7, place de l'église - 30730 Montpezat
Site : https://www.microlinux.fr
Blog : https://blog.microlinux.fr
Mail : info at microlinux.fr
Tél. : 04 66 63 10 32