Install Wordpress on IBM Bluemix

IBM Bluemix is a cloud platform as a service (PaaS) developed by IBM. WordPress is a free and open-source content management system (CMS) based on PHP and MySQL.

Pre-requisites

  1. CloudFoundry CLI
  2. IBM Bluemix account.

Steps in Summary

  1. Download wordpress
  2. Log into CF using the CLI
  3. Create mysql service
  4. Configure wordpress
  5. Create application using the community php buildpack
  6. Bind mysql to the application and confirm configuration
  7. Install wordpress
  8. Optional — Configure wordpress site
  9. Optional — use media storage

Steps in Detail

Step1: Download wordpress from here (I used 4.6.1 as there was a problem with the latest release 4.7 at the time of writing this post)

Step2: Set cloudfoundry API to the bluemix instance

>> cf api https://api.ng.bluemix.net 
Setting api endpoint to https://api.ng.bluemix.net...
OK
API endpoint: https://api.ng.bluemix.net (API version: 2.54.0)

Log into Bluemix

>> cf login
API endpoint: https://api.ng.bluemix.net
...
API endpoint: https://api.ng.bluemix.net (API version: 2.54.0)
User: xxx
Org: xxx
Space: dev

Step3: Create mysql service. The following mysql service is offered at the time of the writing. Note that mysql is provided as an experimental service. Experimental runtimes and services might be unstable or change frequently, and might be discontinued at short notice.

service   plans   description
mysql 100 MySQL database

Create the service:

>> cf create-service mysql 100 mysql-wordpress
Creating service instance mysql-delete in org PRM / space dev as xxx@us.ibm.com...
OK

Step4: Configure wordpress

Step 4.1: wp-config.php — get from here.

Step 4.2: add wp-salt.php to ensure extra security. These salts are used to securely hash the different passwords and cookies used across the site. You can randomly generate the keys at wordpress key generator site. Copy the content of the site into wp-salt.php and save in the same directory as wp-config.php.

Prepend the file with <?php

Step 4.3: copy options.json from here into .bp-config folder

>> mkdir .bp-config
>> touch .bp-config/options.json

Add the following to the options.json file. These extensions are needed for the site to function.

{
"PHP_EXTENSIONS": ["bz2", "zlib", "curl", "mcrypt", "mbstring", "mysqli", "gd", "zip"]
}

Step5: Create application using the community php buildpack. I am calling the application “mywordpress-upkar”

>> cf push mywordpress-upkar -b https://github.com/dmikusa-pivotal/cf-php-build-pack.git --no-manifest --no-start
  • — no-manifest: Ignore manifest file
  • — no-start: Do not start an app after pushing

Step6: Bind mysql to the application and confirm configuration in your wp-config.php.

cf bind-service <appname> <servicename>

cf bind-service mywordpress-upkar mysql-wordpress

Grab the mysql service name from the environment variable and update wp-config.php file with the same.

$mysql_config = $services_json[“mysql-5.5”][0][“credentials”];

Replace mysql-5.5 with the mysql credentials in your apps environment variable. You can see a service credentials using the following command

cf env <appname> (cf env mywordpress-upkar)

In this case, I need to replace “mysql-5.5” with “mysql” as shown by the env output below.

{
“VCAP_SERVICES”: {
“mysql”: [
{
“credentials”: {
...
...
}
}
]
}
}

Push the code changes to Bluemix.

cf push mywordpress-upkar

The push command also starts the application. If the application is not started, you can start is using

cf start mywordpress-upkar

Step7: Install wordpress

The first time you launch your site on bluemix, you will be asked to install wordpress. The URL will look like

https://mywordpress-upkar.mybluemix.net

Step8: Optional — Configure wordpress

upload_max_filesize = 10M
post_max_size = 10M
max_execution_time = 300

You can see the changed upload limit in the media section

Step9: Optional — use media storage

We have a mysql database to support wordpress, but all the media files are stored in the filesystem. You can look at this plugin to store media content on bluemix object-storage database.

Show your support

Clapping shows how much you appreciated upkar’s story.