Deal with the local installation of your Appfog hosted WordPress site

As you might or might not know, this site runs on Appfog hosted WordPress. Since i am just starting this, i am running into all kinds of issues. I have decided that, whenever i find a solution to some problem, i will post about it.

The problem with my Appfog hosted WordPress installation

So the issue i ran into is the fact that Appfog doesn’t have persistent store (yet). That means you have to create your theme, install plugins or do anything in a physical file in a local installation and update the server with this code base.

This presents us with the problem with the database & configuration! My aim wat to get this working:

  • Appfog hosted WordPress
  • Local installation of the site
  • Using the database running at Appfog (so shared among local and live)
  • Not worry about site url’s and stuff

It turns out this is quite possible, it’s not even that hard to set up!

The solution

First of all i assume you know about the af tool Appfog provides. If not, check out this page.

The af tool lets you create a tunnel to any of your bound services. it’s as easy as running af tunnel in your application root. It will present you with login credentials and database name for your MySql service. It also gives you the local port it is bound to:

You can use this information to edit your wp-config.php file. What i did is this:

The environment variable VCAP_SERVICES is set by Appfog so i assume that, whan it’s not there, I’m running the local install. The local settings connect to the tunnel i started using af tunnel.


Now the other problem. For some reason WordPress stores the site url in the database (someone please explain why!). This means everything i did above is useless since I will be redirected to the online version instantly. But luckily it is possible to set these parameters in code as well. Simply add this in the ‘if in local development’ part:

That is basically all there is to it, your appfog hosted WordPress site with local installation to manage your persistent files and a shared database with contextual site url’s is running!

I hope it’s useful for someone. And if there is another way to manage this I’d like to know about it too!

Leave a Reply