Deploying WordPress to Cloud Foundry

One of my goals of today was to figure out how to deploy WordPress to Cloud Foundry. I figured this was a pretty simple goal, but alas there is a trick to it.

Note: I deployed the following to Pivotal Web Services.

  1. Set up your MySQL service instance. To use the PWS ClearDB (MySQL) free tier:
    cf create-service cleardb spark NAMEofINSTANCE
  2. Download the latest version of WordPress:
    wget http://wordpress.org/latest.tar.gz
  • Note: If you are running Mac OS X you can install wget with Homebrew. I did not have success using curl (even with -O) for the download.
  1. Uncompress the file:
    tar xfz latest.tar.gz
  2. Go into the new wordpress directory:
    cd wordpress
  3. Generate the secret keys from the WordPress Secret Key Service
  4. Populate the keys into the appropriate section of the wp-config.php file.
  5. Add the database credentials to the wp-config.php file.*
  1. Add a composer.json file and include the mysqli extension.**
  2. Deploy the application using dmikusa’s PHP buildpack.

* – If you are using PWS, you can view the database credentials by doing the following:

  1. Log into PWS and navigate to the org & space that conatins your app. Click "Manage" next to the service instance (this will open a new window/tab):
  2. Click on the database name:
  3. Go to Endpoint Information:

The parameters needed for wp-config.php (with the info populated from above) are:

db name ad_a448706f10da344
db user b37917c0af0c2a
db password 6858192d
hostname us-cdbr-east-05.cleardb.net

** – The composer.json file should be as follows:

{
  "require": {
    "ext-mysqli": "*"
  }
}

To view my account of figuring out this seemingly simple process, please head over here.

Spread the word

twitter icon facebook icon linkedin icon