Re: Apache and web content permissions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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.

--8<-------------------------------------------------------------
#!/bin/bash
#
# wordpress-update.sh
#
# Mise à jour automatique de toutes les installations Wordpress
#
# (c) Nicolas Kovacs <info@xxxxxxxxxxxxx>

# WP-CLI doit être installé
WP='/usr/local/bin/wp'

# Apache
HTUSER='apache'
HTGROUP='apache'

# Utilisateur normal
WPUSER='microlinux'
WPGROUP='microlinux'

# Racine du serveur Web
WPROOT='/var/www'

# 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
  chown -R $WPUSER:$WPGROUP $WPDIR
  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
done

exit 0
--8<-------------------------------------------------------------

Cheers,

Niki

-- 
Microlinux - Solutions informatiques durables
7, place de l'église - 30730 Montpezat
Site : https://www.microlinux.fr
Blog : https://blog.microlinux.fr
Mail : info@xxxxxxxxxxxxx
Tél. : 04 66 63 10 32
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
https://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]


  Powered by Linux