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.
- Set up your MySQL service instance. To use the PWS ClearDB (MySQL) free tier:
cf create-service cleardb spark NAMEofINSTANCE
- 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 usingcurl
(even with-O
) for the download.
- Uncompress the file:
tar xfz latest.tar.gz
- Go into the new
wordpress
directory:cd wordpress
- Generate the secret keys from the WordPress Secret Key Service
- Populate the keys into the appropriate section of the
wp-config.php
file. - Add the database credentials to the
wp-config.php
file.*
- Alternatively, you may wish to use the environmental variable as seen in dmikusa’s
wp-config.php
file.
- Add a
composer.json
file and include the mysqli extension.** - Deploy the application using dmikusa’s PHP buildpack.
- If you need to add persistent storage, I recommend using dmikusa’s manifest as a template.
* – If you are using PWS, you can view the database credentials by doing the following:
- 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):
- Click on the database name:
- 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.