Importing MySQL on WordPress Cloud Instance

Prerequisites: MySql, VMC, AppFog installed

In prevouse post, i deployed my first PHP app on Cloud. The reasoning for doing was, so i don’t have to configure and maintain my local development infrastructure(Apache, PhpMyAdmin,etc). So, I make a change following with push to cload and the resulting instance on cloud is my development solution ready for testing, however. In order to do, we need import data into MySql on the cloud instance to keep it in sync with production environment. This post is exactly how we accomplish it with ColdeCott  – an extension of CloudFoundry that lets run commands on MySql instance residing on cloud feeding our PHP App

Step 1 – Install DevKit and ColdeCott

DevKit is needed, so we are able to install ColdeCott. To install DevKit, go to rubbyinstaller page and download DevKit. Afterwards, extract DevKit and in ‘Command Line with Ruby’ go to the folder where you extracted DevKit and run the following:

In the above screen shot, the last command was run to install ColdeCotte – ‘get install CaldeCotte’

Step 1 For Mac – Install ColdeCott via XCode

For Mac environments, the Coldecott is installed via XCode as follows:

sudo xcode-select -switch /Applications/   
sudo gem install caldecott

Step 2 – Connect to MySql instance

To connect with the particular MySql instance feeding your app, we use a command ‘tunnel’ from Command Line with Ruby  that establishes the connection. Here is the screen shot:

!!! Before tunneling make sure you are logged in by running ‘af login -u appFogUsername’

The Shell on the left you tunnel(connect to) MySQL instance and afterwards, you are able to run any inquiries you like via mysql command. As you can also see while connecting MySQL, it displayed the current instance username, password and database name that you will need next step when importing data.

Step 3 – Import Data

Once you tunneled in your MySql instance (see shell on the left in the above screen shot), you can use another shell from which you can run mysql command to import data as it is displayed in the shell on the left of the screen shot above

Alternative is to use MySql Workbench with the same credentials given to you in Step 2

!!! Once you close the tunnel(shell), the connection is lost with the MySql instance

!!! The credentials seems to stay the same next time you open connection(tunnel) into the MySql instance

After data imported, we have  our development WordPress app working in sync with production and available for testing without much developers configuring and setting up Apache, PhpMyAdmin,MySql,PHP,etc. Next would be nice to have  Gradle script to do all this for us, so that once me make change, it auto updates our cloud instance but that will be another post….till then, happy coding!


‘Manage you AppFog data from workstation’ by Jeremy Voorihs

Documentation Installing WebKit by the RubyInstaller Google Group


Deploying WordPress using AppFog PaaS

I started this post thinking that i will be able to deploy PHP app on cloud just like Grails app via CloudFoundry Paas.  As i learnt, cloudfoundry directly does not support php technology, however,  if run AppFog on top of cloudfoundry this mission – deploy PHP app such as WordPress on cloud  can be accomplished. This post demonstrates an example of exactly that – WordPress deployed in cloud

In order to use AppFog, we have to do one additional step to process described in post ‘Starting with CloudFoundry on  Windows‘. That is we install AppFog

Step 0 – Installing AppFog

Open Command line with Ruby as described in ‘Starting with CloudFoundry on Windows’ post. From Command line run the following command:

>gem install af

This installed AppFog, so you can use it to deploy WordPress

Step 1 – Sign up for account on

Step 2 – Configure MySql Service

In order our WordPress app to communicate with MySql db in cloud, we have to set cloud environment variables (currently auto-configuration is available only for Node.js under cloudfoundry, however, its possible in near future it will work for other frameworks as well)

So edit wp-config.php as following:

define('DB_NAME', 'dbName');
define('DB_USER', 'dbUser');
define('DB_PASSWORD', 'dbPass');
define('DB_HOST', '');


$services = getenv("VCAP_SERVICES");
$services_json = json_decode($services,true);
$mysql_config = $services_json["mysql-5.1"][0]["credentials"]
define('DB_NAME', $mysql_config["name"]);
define('DB_USER', $mysql_config["user"]);

As you see, ‘getenv(“VCAP_SERVICES”) is way to retrieve cloud instance variables that later is passed to your WordPress app

Step 3 – Deploy on Cloud

Open Command line with Ruby and run following commands:

>af login

This will prompt for username and password you registered Step 1

>af push

Given you are in the root directory of your WordPress app. If not, you specify location by ‘ af push –path somePath’

Afterward, follow the default settings and your application will be published under domain name – yourAppName.cloudDomain that you can also find out by logging into

Next, how do we import MySql data into our WordPress PHP app residing on Cloud? That’s in next post – Importing MySQL on WordPress Cloud Intance