Wordpress on Appfog
In light of a recent event (I launched a site for a friend), I’ve decided to be brave and just fork out for more proper hosting. Rackspace Cloud and my VPS setup have taken care of me for many years; but the rendering speed, high chance of failure, and the ability to easily lose a VPS instance, I’ve decided to move over to Appfog.
Appfog is an awesome web hosting service that I compare to Heroku. You can build locally and you push all the code (CMS and templates) towards the server. This was a bit new for me, I liked to leave the Wordpress core files alone and leave it be so updates can be installed, plugins could be managed in Wordpress, and uploads worked natievely. None of these scenerios really work in Appfog due to its lack of persistant data storage, but it’s well worth losing these benefits for the sheer speed increase you’ll find!
I also am running my sites behind Cloudflare and Amazon S3 for extra speed. I have been dealing with slow school internet for the past 3 years, so these changes make a difference my end enough to justify the work invested in them!
Part 1: Cleanup
Chances are that you want to migrate an existing website to Appfog. You’re going to need to do several things prior to moving over just to make sure your transition moves as smooth as possible.
Wordpress System Backup. The first thing you will want to do is run a Wordpress Backup, from the tools section in the menu. Save this file somewhere you won’t lose it - this is just extra insurance.
Media Backup. Grab
/wp-content/themes/%your_theme%/. Save these both in a safe place. You should also grab anything you need from
SQL Backup. Since your webhosting situation is probably much different than mine, you’re going to need to figure out how to get a SQL dump of your site. Save this file somewhere safe, as well.
Part 2: Next Wordpress
This section deals with preparing the CMS and Template code for pushing to Appfog.
For the sake of keeping things clean, grab the lastest copy of Wordpress from their site. Extract this to your drive and keep it somewhere safe. Give the folder a memorable name.
Grab my config file addictions from Gist. Fill in your local MySQL configuration in the top part. It’s highly recommended that you deploy both locally and to Appfog since updating the Appfog version of a site is a timely process and is best left for batch fixes. Also, grab a copy of this .htaccess for good measure.
/wp-content/into this Wordpress install.
Import your SQL from your live site to your local MySQL install. Point your local Apache to the site as well. See that everything works and is accessible. If not, correct any errors with missing files.
Part 3: Pushing to Appfog
Login to Appfog and create a new PHP project (don’t select the Wordpress option here). Create a MySQL service to go along with it and bind it to your new app.
Grab the Appfog command line utilities
Import your SQL from your live site to Appfog, following these instructions.
- Go to your site directory and push it live like so:
af update %app-name%
- Go to your Appfog URL and verify that it works. If so, congratulations! You have moved your Wordpress site over to Appfog successfully. At this point, you should consider the following optional fixes to enhance your Wordpress experience, espcially if you rely on the Media library or expect your site to be hammered.
Part 4: Miscellaneous Enhancements
Not required, but definitely recommended:
Move some of the static resources from your theme to Amazon S3. It’s crazy cheap, I pay about $.03 monthly for usage of their global CDN. This is a substancial improvement for image load times.
If you rely on Wordpress’ Media Library, Appfog’s non-persistant data store will delete any uploads when you update your server or restart it. Thankfully, an older Wordpress plugin can transparently move new uploads to S3 and link them accordingly so that this isn’t an issue. This plugin works fine despite its lack of updates recently. Any uploads in the
uploads/folder are safe from this rule and it’s only new uploads that need this. If you have any issues with your Visual editor after installing this plugin, you may need to move some localization files for TinyMCE around after installing this plugin.
Place your whole site on Cloudflare which acts as an additional cache for some resources and has a bunch of neat features to speed up and protect your site.
Part 5: Quirks
I guess I probably should have mentioned these before.
- Plugin installs, theme installs, and Wordpress core updates need to be performed from your local environment and pushed live. The config file disables file mods in the production version of your site since Appfog wouldn’t persist those changes.