Translator’s note: This is the 10th article of the series “Cloud Foundry 100-day Challenge selection”. “#045” in the title means that it is 45th (published on August 6, 2015) in the original Japanese series.
Original Author: Kazuto KUSAMA (aka jacopen)
Hello everyone, it’s jacopen, the second striker in Japan Cloud Foundry Group. By the way, hiroakiukaji is the center forward, ozz the chairperson is an attacking midfielder, and nota-ja is a wing back. (Translator’s note: those names are account names of Japan Cloud Foundry Group members.)
Enough about the formation here in CFGRJP, the 45th topic of “Cloud Foundry 100-Day Challenge” is phpMyAdmin, everyone’s favorite.
phpMyAdmin working well with Cloud Foundry
db migratewith predefined schema migrations like Rails, you cannot proceed with your development while you define tables and columns along the way.
So what can you do? You can turn to phpMyAdmin.
I’m sure many of you have heard of phpMyAdmin; it is a MySQL client tool that can be used through a Web browser. As you’ve probably guessed from its name, it is written in PHP.
This time, we will deploy it onto Cloud Foundry, with assuming the structure below. By binding to one service instance from both the application in development and phpMyAdmin, we are able to operate MySQL without affecting the application in development
Prior to deploying phpMyAdmin, I have created a mysql service, just like this:
$ cf create-service mysql default php-mysql-dev OK
In this deployment, we use a version of phpMyAdmin customized for Cloud Foundry.
We can download an archived zip file from the above repository. Let’s unzip it locally,
$ wget https://github.com/cloudfoundry-community/phpmyadmin-cf/archive/cf-ready.zip $ unzip cf-ready.zip $ cd phpmyadmin-cf-cf-ready/
.. then push it to Cloud Foundry. (Note: as the buildpack in Cloud(n) PaaS, a Cloud Foundry-based public PaaS used in this post, was dated, I explicitly specified a PHP buildpack with
$ cf push -b https://github.com/cloudfoundry/php-buildpack.git#v3.2.2 Using manifest file /Users/jacopen/Downloads/phpmyadmin-cf-cf-ready/manifest.yml Updating app phpmyadmin-cfready in org xxxxx / space default as xxxxxxxxxxxx... OK (snip) state since cpu memory disk details #0 running 2015-08-02 05:12:42 PM 0.0% 16M of 1G 102.1M of 2G
After pushing, let’s bind the service to the application then restage.
$ cf bind-service phpmyadmin-cfready php-mysql-dev Binding service php-mysql-dev to app phpmyadmin-cfready in org xxxxxxxxxx / space default as xxxxxxxxxxx... OK TIP: Use 'cf restage phpmyadmin-cfready' to ensure your env variable changes take effect $ cf restage phpmyadmin-cfready Restaging app phpmyadmin-cfready in org xxxxxxxxxx / space default as xxxxxxxxxxxxxxxx..
You will find the default setting of manifest.yml as below. When you would like to change the application name or memory size, you should edit this manifest.yml.
--- #Generated manifest applications: - name: phpmyadmin-cfready memory: 1G instances: 1
It looks like it’s working.
With most services, you can get the username and password for the builtin service through the control panel. Once you get them, go ahead and log in by entering them into phpmyadmin.
It seems that we have succeeded to log in.
And now, we can operate freely the mysql database of the builtin service.
Although there is an authentification process, it is not advisable from a security standpoint to leave phpmyadmin running, so you should either delete or shut down the application once you have finished using it. It is a good point of PaaS that you can easily change the status of an application.
Environment Used in this Post
- CF CLI(cf version 6.10.0-b78bf10-2015-02-11T22:25:45+00:00)
- Cloud Foundry (Cloud(n) PaaS v172)
- phpMyAdmin Cloud Foundry Ready(RELEASE_4_4_0)