About the only thing I miss about hosting my sites on a Linux webhost running Cpanel is the ability to auto update WordPress sites with one click. Granted, my experience with WordPress auto update is a mixed bag. When it works, it is all kinds of awesome. When it doesn’t, it leaves your site inaccessible while you figure out exactly what went wrong and how to fix it.
Since I’ve moved my webhosting to my own colocated Mac mini, I’ve missed the ease of auto updating my WordPress sistes. Downloading the latest WordPress update is such a pain, especially when you have to update several sites each time an update is released. Thankfully, with a little command line code, you can perform this action quite quickly and easily.
First start by SSHing in to your Mac OS X Server. Once in, you will use the ‘curl’ command to download the latest version of WordPress. Thankfully, WordPress keeps it’s latest version at the same URL regardless of version number, so once you make note of this URL, it shouldn’t change.
curl -O http://wordpress.org.latest.zip
Once the download is complete, unzip the archive.
Then change your directory to the wordpress folder.
Now, the final piece is to copy the files in the WordPress folder to the location of your WordPress install. When you do this, make sure you use the ‘-pr’ modifier for the copy command so the copy maintains permissions (-p) and is recursive (-r).
cp -pr * /Library/Webserver/Sites/your-website-name/.
That’s it. You’re done. One of the nice things about the *NIX copy command is that it won’t obliterate directories on the destination if they aren’t present in the source directory. So when you copy the wp-content to the new location, your themes and plugins are all left intact.
In our next tip, we’ll show you how to combine all of these steps in to one script and further automate it.