WordPress – How to deploy it on the a9s Public PaaS

Header Graphic - Blogpost | Wordpress - deploy it on a9s Public PaaS

anynines recently released its a9s MySQL Data Service offering on our a9s Public PaaS. Most of the bloggers around the world use WordPress as their blogging tool.

Now, it is time for all bloggers to host WordPress on our a9s Public PaaS. Let us walk down with all the required steps to install WordPress in this blog post.

Overview

We create an a9s Data Service instance to connect the WordPress application with a MySQL server.

Let us consider an audience with no technical knowledge and also, most of the WordPress users have no technical background and come without any prior knowledge of Cloud Foundry. Come on, let’s deploy a WordPress application smartly on a9s Public PaaS with few steps and experience the magic practically.

Before going ahead to further steps, we would like to assume all the audience have knowledge about command line terminal of any Operating System.

Prerequisites to host WordPress on a9s Public PaaS

To use our a9s Public PaaS to host a WordPress application, you need the following prerequisites:

Choose your a9s MySQL Service Plan

After user creation, run cf login. Please enter your credentials, select your organization name and space name.


$ cf login https://api.de.a9s.eu

Now, we can view all the services available at anynines CF marketplace.

a9s MySQL offers various service plans.

After login, run cf marketplace.

$ cf marketplace -s a9s-mysql101

Getting service plan information for service a9s-mysql101 as your_username...
OK
service plan description free or paid
mysql-cluster-medium a medium replica set paid
mysql-cluster-small a small replica set paid
mysql-single-medium a medium single instance paid
mysql-single-small a small single instance free

 

From the above list, we can choose the required service plan for deploying WordPress. mysql-single-small plan is more than sufficient to deploy WordPress and it is free!

For any custom requirements and queries, please feel free to contact our support.

Create your a9s MySQL Service Instance

To provision a MySQL database, run cf create-service.

$ cf create-service a9s-mysql101 mysql-single-small my-mysql-service

Depending on your infrastructure and service broker utilization, it may take several minutes to create the service instance.

Run cf services to view the creation status. This command displays a list of all your service instances. To view the status of a specific service instance, run

$ cf service NAME-OF-YOUR-SERVICE

Or

$ cf services

Deploy your WordPress Application

After your database is created, we have to follow the below three steps to complete the deployment process:

  1. Download WordPress latest source code.
  2. Modify required configuration.
  3. Start Application and verify.

Download WordPress latest source code.

Download the latest WordPress source code.

$ curl -L -o wordpress-latest.zip https://wordpress.org/latest.zip

Now, extract them and remove zip file:

$ unzip wordpress-latest.zip && rm wordpress-latest.zip

Modify your required configuration

Let us modify the required configuration before pushing the application into our a9s Public PaaS.

Create manifest.yml file by using any text editor with the below  contents inside WordPress directory.

Please edit with your desired application name and route sections shown below. Also, edit services section with the above-created service name.

applications:

- name: <your_app_name>
  memory: 128M

  path: .

  route: .de.a9sapp.eu

  buildpack: php_buildpack

  services:

    - <your_mysql_instance_name>

Now, copy the sample configuration file.

$ cp wordpress/wp-config-sample.php wordpress/wp-config.php

Now edit wordpress/wp-config.php, replace the database configuration lines with the following:

// ** Read MySQL service properties from _ENV['VCAP_SERVICES']
$services = json_decode($_ENV['VCAP_SERVICES'], true);
$service = $services['a9s-mysql101'][0];  // pick the first MySQL service</em>

// ** MySQL settings - You can get this info from your web host ** //
/**
The name of the database for WordPress */
define('DB_NAME', $service['credentials']['name']);

/** MySQL database username */
define('DB_USER', $service['credentials']['username']);

/** MySQL database password */
define('DB_PASSWORD', $service['credentials']['password']);

/** MySQL hostname */
define('DB_HOST', $service['credentials']['hostname'] . ':' . $service['credentials']['port']);

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

Configure the remainder of wp-config.php as you normally would for a new WordPress site.

Before adding extension files, let us create directories inside WordPress directory.

$ mkdir -p .bp-config/php/php.ini.d

Now, create extensions file .bp-config/php/php.ini.d/wp-extensions.ini by using any text editor with the below contents:

extension=mbstring.so
extension=mysqli.so
extension=gd.so
extension=zip.so
extension=openssl.so
extension=sockets.so

Also, create the file .bp-config/options.json and add the following contents:

{
"WEBDIR": "wordpress",
"PHP_VERSION": "{PHP_71_LATEST}"
}

You can also use other PHP versions like replacing PHP_VERSION value with PHP_70_LATEST for PHP 7.0 and so on.

Start your Application and verify

Let us start the application by pushing the application into a9s Public PaaS by using cf push

$ cf push

Now, verify the application by using cf app:

$ cf app

Showing health and status for app wordpress in org your_org_name / space your_space_name as ...

name:              <your_app_name>
requested state:   started
instances:         1/1
usage:             128M x 1 instances
routes:            .de.a9sapp.eu
last uploaded:     Tue 30 Oct 11:18:26 CET 2018
stack:             cflinuxfs2
buildpack:         php_buildpack

state since                                 cpu memory disk details
#0   running   2018-10-30T10:19:11Z   0.2% 96.5M of 128M 234.8M of 512M

Visit http://<your_app_name>.de.a9sapp.eu to set up your WordPress application.

Conclusion

WordPress application deployment can be done with only a few steps on our a9s Public PaaS. This is going to save a lot of time in deployment and configuring your WordPress web server all by yourself.

I hope you are all able to set up WordPress with the above step by step tutorial. Also, please note that Cloud Foundry uploads all of your plugin code inside containers and if you scale your applications or do restage your application, then you have to place plugin code in local source code to get the desired state.

Leave a Reply

Your email address will not be published. Required fields are marked *