Keep Wordpress Updated Easily on Linux
-
We all know that Wordpress is wonderful but also also having new vulnerabilities found in it, etc. Well, if you want to easily keep your Wordpress updated, here is what I do.
There is a way to manage Wordpress via the CLI, which can be found here: http://wp-cli.org/
First,
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Next, check if it works:
php wp-cli.phar --info
Then, to make it executable and able to just type wp, use this:
chmod +x wp-cli.phar sudo mv wp-cli.phar /usr/local/bin/wp
After that, I created a script in the /etc/cron.hourly folder, which may be overkill but that's me, and it does the following:
#!/bin/sh cd /var/www/builtbyart.com wp core update --allow-root wp theme update --all --allow-root wp plugin update --all --allow-root cd /var/www/literaryworksbyaj.com wp core update --allow-root wp theme update --all --allow-root wp plugin update --all --allow-root cd /var/www/thanksaj.com wp core update --allow-root wp theme update --all --allow-root wp plugin update --all --allow-root
So every hour, again I know it's overkill but it's a lightweight thing if nothing needs to be done, it will update the core of Wordpress, the themes, and the plugins for every site on my server. The --allow-root is kind of annoying because you have to be running the command as a root user to execute most of these but you have to allow the command to run as root. Hope that helps someone!
Thanks,
A.J.