Auto update wordpress

Neat trick to always auto update wordpress and plugins.

Pro Tip: You should make regular backups to have something to go back to if the update f*d your site ;-)

First we need to change the permissions and ownership of the web dir.

# Change Owner and Group to SomeUser and WebServerGroup (ftp-user:www-data)
chown -R ftp-user:www-data /path/to/wp
# Change folders to 775 
find /path/to/wp -type d -exec chmod 775 {} \; 
# files op 664 
find /path/to/wp -type f -exec chmod 664 {} \;

Now we need to set the prefered file access method for wordpress.

Open the wp-config.php file and add the following lines:

define('FS_METHOD', 'direct');
define( 'WP_AUTO_UPDATE_CORE', true );

This update uses a MU plugin (Must Use plugin)

This can be achiefed by creating the following directory: wp-content/mu-plugins

All php files in this dir will allways be used by wordpress.

Now create wp-content/mu-plugins/updates.php and add the following content:

add_filter( 'allow_dev_auto_core_updates', '__return_false' ); 
add_filter( 'auto_update_plugin', '__return_true' ); 
add_filter( 'auto_update_theme', '__return_true' );

Now your site will stay up to date ;-)

Cloud & Open-Source magician 🧙‍♂️

I try to find the KISS in complex systems and share it with the world.

comments powered by Disqus